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

/usr/local/bin not writable #24

Closed
grasshoppermouse opened this issue Mar 10, 2018 · 45 comments
Closed

/usr/local/bin not writable #24

grasshoppermouse opened this issue Mar 10, 2018 · 45 comments

Comments

@grasshoppermouse
Copy link

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
Copy link
Member

yihui commented Mar 10, 2018

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
Copy link
Author

That worked. Thanks!

@DavisVaughan
Copy link

+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
Copy link

vnijs commented Sep 18, 2018

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
Copy link
Member

yihui commented Sep 19, 2018

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
Copy link

vnijs commented Sep 19, 2018

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

@yihui
Copy link
Member

yihui commented Oct 12, 2018

@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
Copy link

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
Copy link
Member

yihui commented Oct 25, 2018

@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
Copy link

vnijs commented Jan 9, 2019

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
Copy link
Member

yihui commented Jan 9, 2019

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

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

@jenzopr
Copy link

jenzopr commented Jan 11, 2019

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

@yihui
Copy link
Member

yihui commented Jan 11, 2019

@jenzopr Even after you did what I said above in the first reply? #24 (comment)

@dobrowski
Copy link

dobrowski commented Jan 11, 2019

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
Copy link

Phlogi commented Feb 21, 2019

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 added a commit that referenced this issue Mar 5, 2019
…t know why sometimes the the /usr/bin/osascript hack doesn't work (#24)
@yihui
Copy link
Member

yihui commented Mar 5, 2019

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
Copy link

vnijs commented Mar 6, 2019

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 (4e902ba) that still refers to /usr/local/bin in install.R and checks if that directory is writable. Can you elaborate perhaps?

@yihui
Copy link
Member

yihui commented Mar 6, 2019

@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 #24 (comment): 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., #24 (comment)).

@vnijs
Copy link

vnijs commented Mar 7, 2019

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

@vnijs
Copy link

vnijs commented Sep 1, 2019

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
Copy link

vnijs commented Sep 1, 2019

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 added a commit that referenced this issue Sep 3, 2019
@yihui
Copy link
Member

yihui commented Sep 3, 2019

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

@vnijs
Copy link

vnijs commented Sep 3, 2019

Seems to be working now. Thanks @yihui!

@yihui yihui mentioned this issue Apr 21, 2021
@dragosmg
Copy link

A quick update. I'm currently setting up my Mac with an M1 processor and ran into the same issue. Running Yihui's instructions (#24 (comment)) helped, but the second command should be (for an M1 Mac):

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

@yihui
Copy link
Member

yihui commented May 26, 2021

@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
Copy link

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
Copy link
Member

yihui commented May 28, 2021

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

clrpackages pushed a commit to clearlinux-pkgs/R-tinytex that referenced this issue Jun 2, 2021
…0.32

Charles Teague (1):
      Add AwesomeBox and FontAwesome (#306)

Dirk Elmendorf (1):
      bug: If you set  TINYTEX_VERSION the downloaded version is not named (#302)

Yihui Xie (42):
      if cache = FALSE, remove the downloaded installer on exit (#294)
      cosmetic
      pin the CTAN mirror at https://ctan.math.illinois.edu/systems/texlive/tlnet (#293)
      update supported texlive platforms
      make the `repository` argument also work when install_tinytex() installs the prebuilt binary
      also respect the env var CTAN_REPO in the Windows installer
      unless running on CI servers, reset the CTAN mirror in binary installations since we have fixed it in ff565043d11ef042349d42bcbf178ce0b2a63167; should we fix the CTAN mirror no matter what? I don't know; if only there were a mirror that is based on CDN (then I wouldn't need to worry about which mirror to use)
      Dash doesn't support <<<
      when the env var CI is empty, don't check its value because the LHS of the != comparison would be empty, which would lead to an error
      fix #295: use the env var $OSTYPE in bash to make sure we install the prebuilt TinyTeX binary only for linux but not for other linux distributions such as linux-musl
      missed a space
      support install_tinytex(version = 'latest')
      set the default ctan mirror only when installing TinyTeX on non-CI servers
      store the regular expressions in a list so that I don't have to rely on the indices of items specifically later, e.g. put the first 5 items in r$font so I can test `if (p %in% r$font)` instead of `if (p %in% r[1:5])`
      fix #299: handle the error "! Package pdfx Error: No color profile sRGB_IEC61966-2-1_black_scaled.icc found" and install colorprofiles
      close #301: provide a global option `tinytex.source.install` to make it possible to install TinyTeX via the source installer if need_source_install() fails to make the decision (e.g. on old macOS), in which case users can specify options(tinytex.source.install = TRUE)
      install the dev version of knitr to fix the kableExtra problem https://github.com/yihui/tinytex/runs/2406634462?check_suite_focus=true
      fix ulyngs/oxforddown#4: also detect missing font definition files like LGRcmr.fd and install the missing packages accordingly
      fix #303: include psnfss in the default TinyTeX distribution
      use xfun::format_bytes()
      make sure tinytex is installed before it is used
      try to build tinytex-latexmk
      how come utils is not loaded?
      copy the tinytex binary to the bin/ directory
      copy the tinytex binary to the root dir
      match the binary names first
      mark the file as executable
      fix #311: install the glossary language moduel when a warning is detected:
      also install the language module for datetime2 just like we did for #311
      specify more metadata for the tinytex command
      the executable was also renamed
      add a helper function for myself to open tlmgr.pl without going to the TinyTeX folder every time
      rename the `tinytex` binary to `tinitex` to avoid confusion: tinytex is the R package name, and tinitex will be the command name
      zip is not available on Windows
      don't include the directory structure in the tarball
      compress tinitex.exe inside R via powershell, otherwise appveyor will also try to run powershell on *nix, in which case tinitex.exe won't be found
      not sure why the tarball is empty on Linux
      shouldn't have specified the compression twice
      create the tarball under the directory of tinitex and return the absolute path of the tarball
      still don't know why tar() creates an empty tarball on Linux; try the system command instead
      suppress the messages from `tlmgr option repository`: rstudio/tinytex#24 (comment)
      CRAN release v0.32

christophe dervieux (1):
      update action following changes in r-lib/actions
@marcsteph
Copy link

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 #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
Copy link
Member

yihui commented Aug 5, 2021

@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
Copy link

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 #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
Copy link
Member

yihui commented Nov 9, 2021

@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
Copy link

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

@lensofq
Copy link

lensofq commented Nov 24, 2021

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
Copy link
Member

yihui commented Nov 24, 2021

@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
Copy link

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

@yihui
Copy link
Member

yihui commented Mar 1, 2022

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

@d-linnard
Copy link

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
Copy link
Member

yihui commented May 12, 2022

@d-linnard Please use the exact command above: #24 (comment) That is, you should not replace `whoami` with `dlw` (whoami is a command that returns your username).

@d-linnard
Copy link

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

@seunomo
Copy link

seunomo commented Aug 2, 2022

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
Copy link

seunomo commented Aug 2, 2022

Screenshot 2022-08-02 at 1 29 16 PM

@kundankr4
Copy link

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
Copy link
Member

yihui commented Sep 8, 2023

Input your password, and hit Enter.

@pbchase
Copy link

pbchase commented Dec 29, 2023

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
Copy link
Member

yihui commented Dec 29, 2023

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

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