Closed bbest closed 3 years ago
So despite setting the Linux environment properly with group write permissions (with the umask), the R session overrides to being without group write:
Sys.umask()
# "22"
fs::file_touch("data/test_r.txt")
Sys.umask("002")
fs::file_touch("data/test_r2.txt")
Sys.umask()
# "2"
readr::write_csv(data.frame(a = 1:3), file = "data/test2.csv")
cd /share/github/mhk-env_shiny-apps/data
umask
# 0002
touch test.txt
ls -la | grep test
# -rw-r--r-- 1 bbest staff 0 Mar 4 16:43 test_r.txt
# -rw-rw-r-- 1 bbest staff 0 Mar 4 16:42 test.txt
tail -1 /etc/profile
# umask 002
Then I thought I found where RStudio Server was overriding this here:
https://docs.rstudio.com/ide/server-pro/1.2.1237-1/access-and-security.html#umask
sudo vi /etc/rstudio/rserver.conf
# server-set-umask=0
docker exec -it rstudio bash
but that didn't work.
Sys.umask("2")
in Rprofile.site
Went ahead with overriding user file mask for all users by editing Rprofile.site Managing R with .Rprofile, .Renviron, Rprofile.site, Renviron.site, rsession.conf, and repos.conf – RStudio Support.
Get directory:
R.home(component = "home")
# "/usr/local/lib/R"
Edit Rprofile.site:
sudo vi /usr/local/lib/R/etc/Rprofile.site
Add this line:
Sys.umask("2") # allow group write vs default 22 group read only
Systematically do this once during installation, now in mhk-env_server-software: README.md:
docker exec rstudio sh -c "echo 'Sys.umask('2')\n' >> /usr/local/lib/R/etc/Rprofile.site"
Hi @Neil-Swanson,
I reran all, and hopefully fixed for future :) Wanted to log these for future reference. Also here's the quick for future in Terminal of rstudio.marineenergy.app:
# change directory, eg
/share/github/mhk-env_shiny-apps/data
# change mode as superuser with group write permissions recursively
sudo chmod -R g+w *
bbest@df3e3af5e27f:/share/github/mhk-env.github.io_dev$ ls -la | grep mgt
-rw-rw-r-- 1 bbest staff 339951 Feb 3 19:49 mgt.html
-rw-r--r-- 1 bbest staff 1171 Feb 3 19:48 mgt.Rmd
So we're missing the group write permission.
To add the group write permission, please use the command mentioned previously:
# what's the present working directory?
pwd
# superuser do (sudo) change mode (chmod) recursively (-R) group (g) add (+) write (w) permissions on all (*) files within the present working directory
sudo chmod -R g+w *
# list permissions if mgt file
$ ls -la | grep mgt
-rw-rw-r-- 1 bbest staff 339951 Feb 3 19:49 mgt.html
-rw-r--r-- 1 bbest staff 1171 Feb 3 19:48 mgt.Rmd
# get present working directory
$ pwd
/share/github/mhk-env.github.io_dev
# fix permissions
$ sudo chmod -R g+w *
# check that the write flag to the group got added
$ ls -la | grep mgt
-rw-rw-r-- 1 bbest staff 339951 Feb 3 19:49 mgt.html
-rw-rw-r-- 1 bbest staff 1171 Feb 3 19:48 mgt.Rmd
$ groups nswanson
nswanson : staff sudo shiny
From @Neil-Swanson:
This is a recurring problem despite thinking I fixed it, per mhk-env_server-software: README.md: