I want Rstudio to start in a given working directory.
I am launching Rstudio from a batch script. I'm using the Rocker ML Verse 4.1.1 container. Here is some pseudocode of the batch script:
cat HEREDOC > RSESSION_WRAPPER_FILE
exec &> rsession.log
exec rsession $@
HEREDOC
apptainer run \
"$RSTUDIO_SERVER_IMAGE"
/usr/lib/rstudio-server/bin/rserver \
--rsession-path $RSESSION_WRAPPER_FILE
I have tried many different ways to make the Rstudio session start in a given directory:
cd before calling apptainer
:
cd <directory>
apptainer run ...
cd in the rsession wrapper script:
cat HEREDOC > RSESSION_WRAPPER_FILE
cd <directory>
exec rsession $@
HEREDOC
rsession --session-default-working-dir
:
cat HEREDOC > RSESSION_WRAPPER_FILE
exec rsession $@ --session-default-working-dir <directory>
HEREDOC
rserver --server-working-dir
:
apptainer run --server-working-dir <directory> ...
.Rprofile:
cat HEREDOC > ./.Rprofile
setwd("<directory>")
HEREDOC
.Rprofile and cd in the rsession
wrapper:
cat HEREDOC > RSESSION_WRAPPER_FILE
cd <parent of .Rprofile>
exec rsession $@ --session-default-working-dir <directory>
HEREDOC
cat HEREDOC > ./.Rprofile
setwd("<directory>")
HEREDOC
all to no avail.
I checked for interfering Rprofile files as shown on this stackoverflow answer and found two files:
[1] "/usr/local/lib/R/etc/Rprofile.site"
[2] "/home/simonleary_umass_edu/.Rprofile"
/usr/local/lib/R/etc/*
are all stock from the Rocker container.
Here's the one in my home directory:
.libPaths( c( .libPaths(), "/home/simonleary_umass_edu") )