Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dlejay opened this issue Apr 3, 2020 · 6 comments
Closed

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

dlejay opened this issue Apr 3, 2020 · 6 comments

Comments

@dlejay
Copy link

dlejay commented Apr 3, 2020

/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.

Copy link
Member

Apr 4, 2020

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/

@dlejay
Copy link
Author

dlejay commented Apr 4, 2020

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! 🙂

Copy link
Member

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).

@dlejay
Copy link
Author

dlejay commented Apr 20, 2020

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.

Copy link
Member

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

@milanglacier
Copy link

milanglacier commented May 20, 2023

I personally don't want to use /usr/local/bin by myself. Instead all the executables installed by myself I put them under ~/.local/bin. Since /usr/local/bin is in some sense "owned by" homebrew for intel based macos. What I mean is that homebrew often yields warnings/errors when it found packages that are not installed by homebrew in this path.

Besides, on arm64 based macos, homebrew uses /opt/homebrew instead of /usr/local for installing packages, which makes /usr/local no longer non-root writable.

After reading the installation script, I find that macos and linux are almost similar in most of cases, I just use the same way for installing tinytex in linux in FAQ5 sh -s - --admin --no-path and then I manually symlinked executables under ~/Library/TinyTex/universal-darwin/bin/xxx to ~/.local/bin. And tinytex works pretty fine, I can even directly call tinytex::xelatex("some_file.tex") in R successfully!

I think it would be better that in the documentation of macos installation guide, we could also add a part like this:

In case you prefer not to modify /usr/local/bin, you can refer to FAQ#5 for instructions on how to install tinytex without writing to /usr/local/bin. However, please bear in mind that for proper functionality, many of the executables in the tinytex distribution must be added to your PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants