rstudio / tinytex

A lightweight, cross-platform, portable, and easy-to-maintain LaTeX distribution based on TeX Live
https://yihui.org/tinytex/
Other
982 stars 116 forks source link

/usr/local/bin not writable #24

Closed grasshoppermouse closed 6 years ago

grasshoppermouse commented 6 years ago

I get this error either using either tinytex::install_tinytex() or the os x install script

macOS 10.13.3

add_link_dir_dir: destination /usr/local/bin not writable, no links from /Users/hagen/Library/TinyTeX/bin/x86_64-darwin. add of symlinks had 1 error(s), see messages above. add of symlinks had 1 error(s), see messages above. tlmgr: An error has occurred. See above messages. Exiting.

yihui commented 6 years ago

That is odd. /usr/local/bin should be writable by default on (at least recent versions of) macOS. Anyway, you can run the following code in your terminal (not in the R console). Please run the exact code provided here:

# create the dir if it doesn't exist
[ -e /usr/local/bin ] || sudo mkdir -p /usr/local/bin
# change owner of the dir
sudo chown -R `whoami`:admin /usr/local/bin

Then this in your terminal (do not use sudo here!):

~/Library/TinyTeX/bin/*/tlmgr path add
grasshoppermouse commented 6 years ago

That worked. Thanks!

DavisVaughan commented 6 years ago

+1 just hit this issue on a completely fresh Mac running High Sierra. The informative error message was a life saver. Thanks for the user focused development!

vnijs commented 6 years ago

FYI Of 50+ students using macOS 6 have (sofar) reported this error. I'm providing the hack below to check if /usr/local/bin is writeable and move on with the install process. Is there an easier/cleaner way to do this perhaps?

      if (file.access("/usr/local/bin", mode = 2) == -1) {
        tf <- tempfile()
        cat("#!/bin/bash\nsudo chown -R `whoami`:admin /usr/local/bin\nRscript -e 'tinytex::install_tinytex()'\n", file = tf)
        Sys.chmod(tf, mode = "0755")
        system(paste0('osascript -e \'tell application "Terminal" to activate\' -e \'tell application "Terminal" to do script "', tf, '"\''))
      } else {
        tinytex::install_tinytex()
      }
yihui commented 6 years ago

I can make TinyTeX work without requiring /usr/local/bin to be writable. The only problem is that TinyTeX will only work with tinytex. Writing symlinks to /usr/local/bin will make sure that LaTeX can be found on PATH, hence accessible to other programs in the system.

vnijs commented 6 years ago

"accessible to other programs in the system" is certainly important. Thanks for the great tool @yihui

yihui commented 5 years ago

@vnijs I started working on a new Macbook this week and had this problem myself, so I just applied the trick osascript in install_tinytex() to ask for password to change the owner of /usr/local/bin: 85b626c. Hopefully this will no longer be a problem for macOS users.

zoelzilz commented 5 years ago

Just tried to install using install.packages('tinytex') and tinytex::install_tinytex() in R on MacOS (Mojave) and am having the same issue. But I am VERY very new to this, so could be user error? I have no idea what I'm doing.

yihui commented 5 years ago

@zoelzilz First, please make sure you have installed the latest version of tinytex (>= 0.9). Then when you see a dialog like this, input your password if you trust me:

image

otherwise follow what the error message tells you to do.

vnijs commented 5 years ago

Just as an FYI ... I just worked with a student that was asked for her password to make /usr/local/bin writable and the install still wasn't successful in the end. Weird. See screenshot below. That said, I just installed on a new mac of my own and it worked fine. Go figure.

image

yihui commented 5 years ago

@vnijs Does file.access('/usr/local/bin', 2) return 0?

Can she also try the method I mentioned in my first reply above?

jenzopr commented 5 years ago

Same problem here. file.access('/usr/local/bin', 2) returns -1.

yihui commented 5 years ago

@jenzopr Even after you did what I said above in the first reply? https://github.com/yihui/tinytex/issues/24#issuecomment-372043672

dobrowski commented 5 years ago

I was encountering the same errors as vnijs on HighSierra OS. What finally seemed to work was using the suggesting in comment #2 and then running tinytex::install_tinytex(force = TRUE)

Phlogi commented 5 years ago

This is still an issue. The prompt is not showing up on mac OS to prompt for the users password. Also the documention does not mention the force=TRUE option. Could you add that to: https://yihui.name/tinytex/?

yihui commented 5 years ago

Please try the current development version of tinytex. It no longer requires /usr/local/bin to be writable. Things should work out of the box if you are compiling R Markdown to PDF or calling tinytex::latexmk() to compile LaTeX documents.

vnijs commented 5 years ago

Thanks @yihui. I used tinytex::uninstall_tinytex() and then tinytex::install_tinytex() and it seems the TinyTex is now installed into /Users/username/Library/TinyTex. That seems like a great idea and everything seems to work fine so far. That said, I'm a bit confused by the latest commit (https://github.com/yihui/tinytex/commit/4e902ba0e635862d7d7bf12714af7d3f11cfe2e1) that still refers to /usr/local/bin in install.R and checks if that directory is writable. Can you elaborate perhaps?

yihui commented 5 years ago

@vnijs There was no change in the installation dir (it has always been ~/Library/TinyTeX). The change was that I'd attempt to create symlinks from ~/Library/TinyTeX to /usr/local/bin, and if it fails, I'd give up instead of signaling an error (as I did before). If you compile LaTeX documents through the R package tinytex (which is what the rmarkdown package does), I won't require LaTeX symlinks under /usr/local/bin.

The downside is as I said previously at https://github.com/yihui/tinytex/issues/24#issuecomment-422634621: if those symlinks are not under /usr/local/bin, it means TinyTeX cannot be called directly by other software packages in the system without using the full path. This is not a concern for R Markdown users. Compared to the constant confusion caused by the /usr/local/bin that is not writable, I feel this is an acceptable downside. What's more, if anyone is really bitten by this issue, I have provided the solution in the very first reply in this thread (i.e., https://github.com/yihui/tinytex/issues/24#issuecomment-372043672).

vnijs commented 5 years ago

Got it. Thanks @yihui. It seems like everything is working fine. If my students do hit any snags I'll let you know.

vnijs commented 5 years ago

FYI Some of my students still seem to be having problems installing tinytex on macOS because /usr/local/bin is not writable (see message below). I'll be able to investigate in more detail when I see the students in a few weeks.

done running updmap-sys.
regenerating fmtutil.cnf in /Users/ross/Library/TinyTeX/texmf-dist
running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine tex ...
done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine tex.
running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt mf ...
done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt mf.
tlmgr: package log updated: /Users/ross/Library/TinyTeX/texmf-var/web2c/tlmgr.log
add_link_dir_dir: destination /usr/local/bin not writable, no links from /Users/ross/Library/TinyTeX/bin/x86_64-darwin.
add of symlinks had 1 error(s), see messages above.
tlmgr: An error has occurred. See above messages. Exiting.
Error: Failed to install TinyTeX
vnijs commented 5 years ago

I just created a new user account on my mac and was able to reproduce the problem (see below for latest version on CRAN 0.15). Tinytex still asks to run a script to change permissions but install fails at the end. Any suggestions?

running mktexlsr ...
done running mktexlsr.
running updmap-sys ...
done running updmap-sys.
regenerating fmtutil.cnf in /Users/rsm-vnijs/Library/TinyTeX/texmf-dist
running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine tex ...
done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine tex.
running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt mf ...
done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt mf.
tlmgr: package log updated: /Users/rsm-vnijs/Library/TinyTeX/texmf-var/web2c/tlmgr.log
add_link_dir_dir: destination /usr/local/bin not writable, no links from /Users/rsm-vnijs/Library/TinyTeX/bin/x86_64-darwin.
add of symlinks had 1 error(s), see messages above.
tlmgr: An error has occurred. See above messages. Exiting.
yihui commented 5 years ago

@vnijs Should be fixed now. Thanks for the report and reproducing the issue!

vnijs commented 5 years ago

Seems to be working now. Thanks @yihui!

dragosmg commented 3 years ago

A quick update. I'm currently setting up my Mac with an M1 processor and ran into the same issue. Running Yihui's instructions (https://github.com/yihui/tinytex/issues/24#issuecomment-372043672) helped, but the second command should be (for an M1 Mac):

~/Library/TinyTeX/bin/universal-darwin/tlmgr path add

yihui commented 3 years ago

@dragosmg Thank you! I just updated my instruction above to use the wildcard (i.e. ~/Library/TinyTeX/bin/*/tlmgr) so that the system architecture won't matter.

MariaQuintero commented 3 years ago

Hello! I am new in R. I need to download files in pdf but I am having this error. Anyone can help me please?

tinytex::install_tinytex(force = TRUE) tlmgr option repository 'ctan' tlmgr: setting default package repository to https://mirror.ctan.org/systems/texlive/tlnet

yihui commented 3 years ago

@MariaQuintero I don't see any error. I see a message. If that is what you meant, you can safely ignore the message.

marcsteph commented 3 years ago

Hi there I was trying to instal tinytex to R on mac (big sur) and I got this message. How do I check if tinytex already installed?

thank you

install.packages('tinytex') trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.1/tinytex_0.32.tgz' Content type 'application/x-gzip' length 120964 bytes (118 KB)

downloaded 118 KB

The downloaded binary packages are in /var/folders/6d/z47gjjtj2nddcb7bz6g8b2_00000gn/T//Rtmp48LdEA/downloaded_packages

tinytex::install_tinytex() The directory /usr/local/bin is not writable. I recommend that you make it writable. See https://github.com/yihui/tinytex/issues/24 for more info.

trying URL 'https://yihui.org/tinytex/TinyTeX-1.tgz' Content type 'application/octet-stream' length 86955319 bytes (82.9 MB)

downloaded 82.9 MB

add_link_dir_dir: destination /usr/local/bin not writable, no links from /Users/marcosteph/Library/TinyTeX/bin/universal-darwin. tlmgr: An error has occurred. See above messages. Exiting. TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above.

yihui commented 3 years ago

@marcsteph Please either see my very first reply in this thread to fix the problem, or ignore the message if you use TinyTeX from R.

Xingyue-Chen commented 2 years ago

Hello,@yihui When I tried to install the TinyTeX, it shows that: The directory /usr/local/bin is not writable. I recommend that you make it writable. See https://github.com/yihui/tinytex/issues/24 for more info.

add_link_dir_dir: destination /usr/local/bin not writable, no links from /Users/xingyue.chen/Library/TinyTeX/bin/universal-darwin. tlmgr: An error has occurred. See above messages. Exiting.

And then I used the above codes sudo chown -R whoami:admin /usr/local/bin but it shows that unexpected symbol在"sudo chown"里

what is the problem? thank you

yihui commented 2 years ago

@Xingyue-Chen The problem is that you ran the code in the R console, but should really run it in your terminal. I've added emphasis in my first reply.

JosiahParry commented 2 years ago

Another note that this worked liked a charm! Thanks Yihui!

lensofq commented 2 years ago

I get error message after both: sudo chown -R whoami:admin /usr/local/bin chown: /usr/local/bin: No such file or directory

~/Library/TinyTeX/bin/*/tlmgr path add mkdir(/usr/local/bin/) failed for tree /usr/local/bin: Permission denied TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above. tlmgr: An error has occurred. See above messages. Exiting.

yihui commented 2 years ago

@tortoisenme I don't know how it could be possible that /usr/local/bin doesn't exist, but you can create it anyway:

sudo mkdir -p /usr/local/bin
KingxSlayer commented 2 years ago

I ran the code into my terminal but when it asks for a password it wont let me write anything

yihui commented 2 years ago

@KingxSlayer Just type the password. Nothing will show up as you type, but that's normal.

d-linnard commented 2 years ago

I am seeing similar issue. When I try tinytex::install_tinytex() I get

The directory /usr/local/bin is not writable. I recommend that you make it writable. See https://github.com/yihui/tinytex/issues/24 for more info.

trying URL 'https://yihui.org/tinytex/TinyTeX-1.tgz'
Content type 'application/octet-stream' length 88429277 bytes (84.3 MB)
==================================================
downloaded 84.3 MB

add_link_dir_dir: destination /usr/local/bin not writable, no links from /Users/dlw/Library/TinyTeX/bin/universal-darwin.
tlmgr: An error has occurred. See above messages. Exiting.
TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above

When I try the solution @yihui I get:

Screen Shot 2022-05-11 at 9 40 56 PM

Do you see what I am doing wrong here?

Thank you!

yihui commented 2 years ago

@d-linnard Please use the exact command above: https://github.com/yihui/tinytex/issues/24#issuecomment-372043672 That is, you should not replace `whoami` with `dlw` (whoami is a command that returns your username).

d-linnard commented 2 years ago

Beautiful! Thank you, @yihui! I appreciate your time!

seunomo commented 2 years ago

Tried all instructions given above in order to be able to knit to pdf on rstudio but still giving directory error.

Got message :

trying URL 'https://yihui.org/tinytex/TinyTeX-1.tgz'
Content type 'application/octet-stream' length 88706703 bytes (84.6 MB)
==================================================
downloaded 84.6 MB

tlmgr install tlgpg
tlmgr install: package tlgpg not present in repository.
tlmgr: action install returned an error; continuing.
tlmgr: package repository https://ftpmirror1.infania.net/mirror/CTAN/systems/texlive/tlnet (verified)
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr update --self
tlmgr install tlgpg
tlmgr install: package tlgpg not present in repository.
tlmgr: action install returned an error; continuing.
tlmgr: package repository https://ftpmirror1.infania.net/mirror/CTAN/systems/texlive/tlnet (verified)
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr --repository http://www.preining.info/tlgpg/ install tlgpg
tlmgr: package repository http://www.preining.info/tlgpg/ (not verified: pubkey missing)
[1/2, ??:??/??:??] install: tlgpg.universal-darwin [752k]
[2/2, 00:01/00:01] install: tlgpg [1k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /Users/seunomoniyi/Library/TinyTeX/texmf-var/web2c/tlmgr.log
tlmgr: command log updated: /Users/seunomoniyi/Library/TinyTeX/texmf-var/web2c/tlmgr-commands.log
tlmgr option repository 'https://ftpmirror1.infania.net/mirror/CTAN/systems/texlive/tlnet'
tlmgr: setting default package repository to https://ftpmirror1.infania.net/mirror/CTAN/systems/texlive/tlnet
tlmgr: updating /Users/seunomoniyi/Library/TinyTeX/tlpkg/texlive.tlpdb
tlmgr update --list
tlmgr: package repository https://ftpmirror1.infania.net/mirror/CTAN/systems/texlive/tlnet (verified)
tlmgr: no updates available
seunomo commented 2 years ago
Screenshot 2022-08-02 at 1 29 16 PM
kundankr4 commented 1 year ago

That is odd. /usr/local/bin should be writable by default on (at least recent versions of) macOS. Anyway, you can run the following code in your terminal (not in the R console). Please run the exact code provided here:

# create the dir if it doesn't exist
[ -e /usr/local/bin ] || sudo mkdir -p /usr/local/bin
# change owner of the dir
sudo chown -R `whoami`:admin /usr/local/bin

Then this in your terminal (do not use sudo here!):

~/Library/TinyTeX/bin/*/tlmgr path add

it ask for a password. what should i do?

yihui commented 1 year ago

Input your password, and hit Enter.

pbchase commented 9 months ago

I do believe the procedures here work fine if there is only one account on a Mac, but they don't work if there is a second account and both users want to use TinyTex. The first user will install TinyTex in their home directory, making the symlinks in /usr/local/bin/ that point at files in ~/Library/TinyTeX/bin/*/. The second user can't reach those files so TinyTex fails for them. If the second user tries to install TinyTex, they can do everything except make the symlinks. If they do manage to run the procedures above, they will break TinyTex for the other user.

The solution is for the second user to install TinyTex, allow the symlink step to fail, then adjust their path to include the ~/Library/TinyTeX/bin/*/ directory. Or they can symlink the files in ~/Library/TinyTeX/bin/*/ into some other private folder that is already in the path. I did the latter and TinyTex works fine for both users now.

yihui commented 9 months ago

@pbchase You are absolutely correct. Thanks for sharing the solution!