Skip to content

Commit

Permalink
1. /usr/local/bin may not even exist, so try to create it if it doesn…
Browse files Browse the repository at this point in the history
…'t exist; 2. use `chown` in the installation script if /usr/local/bin is not writable
  • Loading branch information
yihui committed Sep 8, 2022
1 parent efd0cd1 commit a13ae48
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: tinytex
Type: Package
Title: Helper Functions to Install and Maintain TeX Live, and Compile LaTeX Documents
Version: 0.41.2
Version: 0.41.3
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre", "cph"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person(family = "RStudio, PBC", role = "cph"),
Expand Down
16 changes: 10 additions & 6 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,21 @@ win_app_dir = function(..., error = TRUE) {

# check if /usr/local/bin on macOS is writable
check_local_bin = function() {
if (os_index != 3 || is_writable('/usr/local/bin')) return()
chown_cmd = 'chown -R `whoami`:admin /usr/local/bin'
if (os_index != 3 || is_writable(p <- '/usr/local/bin')) return()
message(
'The directory /usr/local/bin is not writable. I recommend that you ',
'make it writable. See https://github.com/rstudio/tinytex/issues/24 for more info.'
'The directory ', p, ' is not writable. I recommend that you make it writable. ',
'See https://github.com/rstudio/tinytex/issues/24 for more info.'
)
if (!dir_exists(p)) osascript(paste('mkdir -p', p))
osascript(paste('chown -R `whoami`:admin', p))
}

osascript = function(cmd) {
if (system(sprintf(
"/usr/bin/osascript -e 'do shell script \"%s\" with administrator privileges'", chown_cmd
"/usr/bin/osascript -e 'do shell script \"%s\" with administrator privileges'", cmd
)) != 0) warning(
"Please run this command in your Terminal (password required):\n sudo ",
chown_cmd, call. = FALSE
cmd, call. = FALSE
)
}

Expand Down
14 changes: 14 additions & 0 deletions tools/install-bin-unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,18 @@ fi
[ $OSNAME != "Darwin" ] && ./tlmgr option sys_bin $BINDIR
./tlmgr postaction install script xetex # GH issue #313
([ -z $CI ] || [ $(echo $CI | tr "[:upper:]" "[:lower:]") != "true" ]) && ./tlmgr option repository ctan

if [ $OSNAME = 'Darwin' ]; then
# create the dir if it doesn't exist
if [ ! -d /usr/local/bin ]; then
echo "Admin privilege (password) is required to create the directory /usr/local/bin:"
sudo mkdir -p /usr/local/bin
fi
# change owner of the dir
if [ ! -w /usr/local/bin ]; then
echo "Admin privilege (password) is required to make /usr/local/bin writable:"
sudo chown -R `whoami`:admin /usr/local/bin
fi
fi

./tlmgr path add

0 comments on commit a13ae48

Please sign in to comment.