Tinytex: Shell script install fails: /usr/local/bin is not writable

Created on 3 Apr 2020  Â·  5Comments  Â·  Source: yihui/tinytex

/usr/local/bin is owned by root by default, so the user cannot symlink anything to it.

It seems that this issue has been addressed in R (I don't use R) but is still present with the shell scripts.

Would it be possible to change the install script so as to let the user choose between an
install to /urs/local/bin and a local install without running sudo?


By filing an issue to this repo, I promise that

  • [v] I have fully read the issue guide at https://yihui.org/issue/.
  • [v] 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.

  • [v] 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.

Most helpful comment

Absolutely, I understand why this choice has been made.

What I want to point out is a couple tiny incoherences.

The doc says:

Installing or running TinyTeX does not require admin privileges.

Strictly speaking, a ‘standard user’ on macOS needs to change ownership of /usr/local/bin for the script to install TinyTex completely. This requires admin privileges.

Also, the doc says:

TinyTeX assumes that you are not afraid of using the command line. If you are, please use other popular LaTeX distributions instead.

So I guess it could mean that people should know how to change their PATH.

Anyway, I suggest making a few changes. Either change the shell script (to test the different cases) or change the documentation and tell the user just before

For macOS users, TinyTeX will be installed to ~/Library/TinyTeX, and executables are symlinked to /usr/local/bin:

that they need to own /usr/local/bin or change their PATH as you suggested. In the first case, it could be nice to add

sudo chown -R $(whoami) /usr/local/bin

to the doc. In the second case, the script would still fail, so it could be good to modify it slightly.

All 5 comments

Homebrew also uses /usr/local (including /usr/local/bin): https://docs.brew.sh/FAQ#why-does-homebrew-prefer-i-install-to-usrlocal

If your /usr/local/bin is owned by root, there is probably something wrong, which can be fixed by:

sudo chown -R $(whoami) /usr/local/bin

If you don't want to do that, you can just safely ignore the error message when the installation script _tries_ to create symlinks to /usr/local/bin (and fails to).

If you really don't like the harmless error message, use the two additional options in FAQ 5: https://yihui.org/tinytex/faq/

if your /usr/local/bin is owned by root, there is probably something wrong,

On a default macOS machine, everything under /usr/local/ is owned by root.
The Homebrew install script changes the owner of /usr/local/bin and other directories with the command that you described. Some people consider changing the default owner of /usr/local/bin to be unorthodox and recommend against doing it as it is a security risk.
Before 2015, Homebrew would even change the owner of /usr/local. Starting from 2015, Apple forbids anyone to do so and /usr/local now is always owned by root.

The script as it is, somehow assumes that the user is already a Homebrew user (I have not seen another case where people would change the owner of /usr/local/bin) and it will fail to install a functional tex. I think this defeats the idea of ‘installing TinyTex with a one-line-copy-paste’.

Changing the owner of /usr/local/bin requires sudo, I think this would also defeat the idea of ’installing TinyTex does not require sudo’.

A particular use case scenario is: you are using a macOS computer that is not yours (a University one, let's say) and you would like do some TeXing. For this, the installation must be sudoless (to not rely on IT) and small (to be installed quickly): TinyTex! 🙂

The root issue is the environment variable PATH. If you know how to add a path to PATH, you are all set (add ~/Library/TinyTeX/bin/x86_64-darwin to PATH), and you don't need sudo. The problem is that not everyone knows how to do that on every platform. That's why /usr/local/bin is handy (it is already in PATH).

Absolutely, I understand why this choice has been made.

What I want to point out is a couple tiny incoherences.

The doc says:

Installing or running TinyTeX does not require admin privileges.

Strictly speaking, a ‘standard user’ on macOS needs to change ownership of /usr/local/bin for the script to install TinyTex completely. This requires admin privileges.

Also, the doc says:

TinyTeX assumes that you are not afraid of using the command line. If you are, please use other popular LaTeX distributions instead.

So I guess it could mean that people should know how to change their PATH.

Anyway, I suggest making a few changes. Either change the shell script (to test the different cases) or change the documentation and tell the user just before

For macOS users, TinyTeX will be installed to ~/Library/TinyTeX, and executables are symlinked to /usr/local/bin:

that they need to own /usr/local/bin or change their PATH as you suggested. In the first case, it could be nice to add

sudo chown -R $(whoami) /usr/local/bin

to the doc. In the second case, the script would still fail, so it could be good to modify it slightly.

@dlejay Your suggestions make perfect sense! I'll update the docs. Thank you so much!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

boltomli picture boltomli  Â·  3Comments

leafyeh7 picture leafyeh7  Â·  6Comments

tbradley1013 picture tbradley1013  Â·  7Comments

solomoncharles77 picture solomoncharles77  Â·  6Comments

randrescastaneda picture randrescastaneda  Â·  5Comments