You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just installed tinytex for the first time on a Linux system (Ubuntu 20.04). First of all: Great project, thank you!
Now to my problem: While it's possible to customize the tinytex installation path (aka tinytex "root") via tinytex::install_tinytex()'s dir param, there doesn't seem to exist any means to set/customize the user bin folder where tinytex places the symlinks after successful installation. Instead of the default ~/bin I'd like to use ~/.local/bin (which is the default defined in the XDG Base Directory Specification).
This wouldn't be that much of a problem if I could just manually move the symlinks and forget about it. But tinytex regenerates the ~/bin dir with all symlinks everytime tinytex::tlmgr_install() is executed. Is there any environment variable I could set to avoid this? Or anything else I've missed?
I have provided the necessary information about my issue.
If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('tinytex'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/tinytex').
If I have posted the same issue elsewhere, I have also mentioned it in this issue.
I have learned the Github Markdown syntax, and formatted my issue correctly.
I understand that my issue may be closed if I don't fulfill my promises.
I believe tinytex is only calling tinytex::tlmgr_path() when add_path = TRUE in the install function. This tlmgr_path() is a thin wrapper around tlmgr path add CLI command. Doc is here: https://www.tug.org/texlive/doc/tlmgr.html#path
On Unix, adds or removes symlinks for executables, man pages, and info pages in the system directories specified by the respective options (see the "option" description above).
You can check the value of the option using tinytex::tlmgr(c("option", "sys_bin")) or all options using tinytex::tlmgr(c("option", "showall")) (or obviously directly in terminal with tlmgr)
Which is the value set ?
I believe you can change this value quiet easily using tlmgr option sys_bin <new value> or tinytex::tlmgr(c("option", "sys_bin", "<new_path>")
This should change the behavior to the tlmgr_path() function. So probably order would be
Install TinyTeX with add_path = FALSE
Run tinytex::tlmgr(c("options", "sys_bin", "<new_path>")
I can definitely set it to ~/.local/bin instead, but I just checked the PATH variable on Ubuntu 20.04, and found that it did not contain ~/.local/bin. ~/bin is still present in PATH. It seems that it's not a good idea to set sys_bin to ~/.local/bin yet, otherwise users will have to adjust PATH manually.
@yihui Yes, I agree that it's too early to change the default. It's a recurring issue on Ubuntu and I don't know what their immediate plans are. Since Ubuntu uses systemd and systemd is a freedesktop.org project adhering to the XDG Base Directory Specification (easily verified by running systemd-path user-binaries which should give /home/username/.local/bin), I think eventually they will make the switch.
We could think about introducing an additional param bin_dir or the like in tinytex::install_tinytex() but maybe it's not worth the hassle. I can live fine with the workaround outlined by @cderv.
Okay, I just made a change so that ~/.local/bin will be used if it exists. The rationale is that this directory shouldn't exist by default. If it does, I assume that the user really prefers it over ~/bin. That should fix your problem.
Alternatively, I could check if ~/.local/bin is present on PATH instead of merely checking if this directory exists, but I guess the latter might be enough for *nix users.
diff --git a/R/install.R b/R/install.R
index 4d6ac31..65a2f49 100644
--- a/R/install.R+++ b/R/install.R@@ -411,7 +411,9 @@ install_prebuilt = function(
# post-install configurations
post_install_config = function(add_path, extra_packages, repo, hash = FALSE) {
if (os_index == 2) {
- if (!dir_exists(bin_dir <- '~/.local/bin')) dir.create(bin_dir <- '~/bin', FALSE, TRUE)+ bin_dir = '~/.local/bin'+ if (!path.expand(bin_dir) %in% env_paths()) bin_dir = '~/bin'+ dir.create(bin_dir, FALSE, TRUE)
tlmgr(c('option', 'sys_bin', bin_dir))
}
# fix fonts.conf: https://github.com/yihui/tinytex/issues/313
@@ -430,6 +432,11 @@ post_install_config = function(add_path, extra_packages, repo, hash = FALSE) {
}
}
+# get paths on the PATH variable+env_paths = function() {+ unlist(strsplit(Sys.getenv('PATH'), .Platform$path.sep, fixed = TRUE))+}+
download_installer = function(file, version) {
url = if (version != '') sprintf(
'https://github.com/yihui/tinytex-releases/releases/download/v%s/%s', version, file
diff --git a/tools/install-bin-unix.sh b/tools/install-bin-unix.sh
index b0a3393..f2bf897 100755
--- a/tools/install-bin-unix.sh+++ b/tools/install-bin-unix.sh@@ -60,10 +60,13 @@ fi
cd $TEXDIR/bin/*/
+# if ~/.local/bin is on PATH, use it as sys_bin; otherwise use ~/bin
BINDIR="$HOME/.local/bin"
-if [ ! -d $BINDIR]; then+if [[ "$PATH" =~ (^|:)"${BINDIR}"(:|$) ]]; then+else
BINDIR="$HOME/bin"
fi
+mkdir -p $BINDIR
[ $OSNAME != "Darwin" ] && ./tlmgr option sys_bin $BINDIR
./tlmgr postaction install script xetex # GH issue #313
Alternatively, I could check if ~/.local/bin is present on PATH instead of merely checking if this directory exists, but I guess the latter might be enough for *nix users.
FWIW I would need to recheck but I think ~/.local/bin is on PATH on Ubuntu inside GHA but not created.
Okay, if that's the case, my current fix should work, and the alternative fix could be problematic (would need to check for the existence of the dir or create the dir).
Okay, I just made a change so that ~/.local/bin will be used if it exists. The rationale is that this directory shouldn't exist by default. If it does, I assume that the user really prefers it over ~/bin. That should fix your problem.
Activity
cderv commentedon Apr 13, 2022
Hi,
I believe tinytex is only calling
tinytex::tlmgr_path()whenadd_path = TRUEin the install function. Thistlmgr_path()is a thin wrapper aroundtlmgr path addCLI command. Doc is here: https://www.tug.org/texlive/doc/tlmgr.html#pathYou can check the value of the option using
tinytex::tlmgr(c("option", "sys_bin"))or all options usingtinytex::tlmgr(c("option", "showall"))(or obviously directly in terminal withtlmgr)Which is the value set ?
I believe you can change this value quiet easily using
tlmgr option sys_bin <new value>ortinytex::tlmgr(c("option", "sys_bin", "<new_path>")This should change the behavior to the
tlmgr_path()function. So probably order would beadd_path = FALSEtinytex::tlmgr(c("options", "sys_bin", "<new_path>")tinytex::tlmgr_path()So afterall it is a
tlmgrthing IMO.Hope it helps
salim-b commentedon Apr 13, 2022
Hi @cderv, thanks a lot for the detailed response!
Awesome, that worked!
I've proposed a new FAQ item in yihui/yihui.org#171 about this as well as yihui/yihui.org#172 :)
yihui commentedon Apr 13, 2022
Yes, on Linux, the
sys_binoption is currently set to~/binin the R function:https://github.com/yihui/tinytex/blob/c3a71c782054e000949c42b1ec547d737e1d11bf/R/install.R#L404
and in the shell script:
https://github.com/yihui/tinytex/blob/c3a71c782054e000949c42b1ec547d737e1d11bf/tools/install-bin-unix.sh#L62
I can definitely set it to
~/.local/bininstead, but I just checked thePATHvariable on Ubuntu 20.04, and found that it did not contain~/.local/bin.~/binis still present inPATH. It seems that it's not a good idea to setsys_binto~/.local/binyet, otherwise users will have to adjustPATHmanually.salim-b commentedon Apr 14, 2022
@yihui Yes, I agree that it's too early to change the default. It's a recurring issue on Ubuntu and I don't know what their immediate plans are. Since Ubuntu uses systemd and systemd is a freedesktop.org project adhering to the XDG Base Directory Specification (easily verified by running
systemd-path user-binarieswhich should give/home/username/.local/bin), I think eventually they will make the switch.We could think about introducing an additional param
bin_diror the like intinytex::install_tinytex()but maybe it's not worth the hassle. I can live fine with the workaround outlined by @cderv.use ~/.local/bin as the system bin path of TeX Live if it exists, othβ¦
yihui commentedon Apr 14, 2022
Okay, I just made a change so that
~/.local/binwill be used if it exists. The rationale is that this directory shouldn't exist by default. If it does, I assume that the user really prefers it over~/bin. That should fix your problem.Alternatively, I could check if
~/.local/binis present onPATHinstead of merely checking if this directory exists, but I guess the latter might be enough for *nix users.cderv commentedon Apr 14, 2022
FWIW I would need to recheck but I think
~/.local/binis on PATH on Ubuntu inside GHA but not created.yihui commentedon Apr 14, 2022
Okay, if that's the case, my current fix should work, and the alternative fix could be problematic (would need to check for the existence of the dir or create the dir).
salim-b commentedon Apr 14, 2022
Great, much appreciated!