Skip to content

Commit

Permalink
a more robust fix to #181: make sure Sys.which('tlmgr') is a symlink …
Browse files Browse the repository at this point in the history
…created by `tlmgr path add` (not 100% sure, but should be fairly sure under these conditions)
  • Loading branch information
yihui committed May 13, 2020
1 parent 61be403 commit dcaa912
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions R/tlmgr.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,20 @@ tlmgr_install = function(pkgs = character(), usermode = FALSE, path = !usermode
}
if (Sys.which('gs') == '') warning('GhostScript is required for the epstopdf package.')
}
# only run `tlmgr path add` if the symlink for tlmgr exists under
# /usr/local/bin; it may not exist when TinyTeX is installed with --no-path
if (missing(path)) path = path && file.exists('/usr/local/bin/tlmgr')
if (missing(path)) path = path && need_add_path()
if (path) tlmgr_path('add')
invisible(res)
}

# we should run `tlmgr path add` after `tlmgr install` only when the `tlmgr`
# found from PATH is a symlink that links to another symlink (typically under
# TinyTeX/bin/platform/tlmgr, which is typically a symlink to tlmgr.pl)
need_add_path = function() {
(p <- Sys.which('tlmgr')) != '' && is_writable(p) &&
(p2 <- Sys.readlink(p)) != '' && basename(Sys.readlink(p2)) == 'tlmgr.pl' &&
basename(dirname(dirname(p2))) == 'bin'
}

is_writable = function(p) file.access(p, 2) == 0

# check of certain LaTeX packages are installed: if installed, `tlmgr info pkgs`
Expand Down

0 comments on commit dcaa912

Please sign in to comment.