rocker-org / rocker-versioned

Run current & prior versions of R using docker
https://hub.docker.com/r/rocker/r-ver
GNU General Public License v2.0
297 stars 169 forks source link

Proper use of rstudio-prefs.json and setting RStudio defaults #266

Closed ATpoint closed 2 years ago

ATpoint commented 2 years ago

Hi, I am wondering how to make Rocker respect RStudio setting defined in rstudio-prefs.json.

That file is:

{
    "jobs_tab_visibility": "shown",
    "initial_working_directory": "~",
    "editor_theme": "Idle Fingers",
    "posix_terminal_shell": "bash",
    "restore_source_documents": false,
    "save_workspace": "never",
    "load_workspace": false,
    "always_save_history": false,
    "restore_last_project": false
    "soft_wrap_rmd_files": false,
    "rmd_chunk_output_inline": false,
    "auto_run_setup_chunk": false,
    "hide_console_on_chunk_execute": false
}

and based on what I read in previous issues I do in the Dockerfile:

COPY rstudio-prefs.json /etc/rstudio/rstudio-prefs.json

...but this doesn't seem to do the trick as each a) RStudio does not use these settings and b) RStudio seems to favour local .Rhistory and .Rprofile leftovers (if they exist) when running:

docker run -d -p 8787:8787 \
  --mount type=bind,source="$(pwd)",destination=/home/rstudio/ \
  -e PASSWORD=pw -e ROOT=TRUE name/image:tag

Based on https://github.com/rocker-org/rocker-versioned/issues/79 the autosave and auto-restore should be off, is it? But that's what I see:

rstudio

Any pointers what I am doing wrong? Thanks!

eitsupi commented 2 years ago

I believe RStudio configuration files are located in user directories such as ~/.rstudio in the past and ~/.config/rstudio now. What version of RStudio are you using? In any case, it is recommended to check the files generated in the above directories after changing the settings in RStudio.

ATpoint commented 2 years ago

Thanks for the prompt reply. It's RStudio Server 2021.09.0 Build 351 from the current Rocker 4.1.2.

eitsupi commented 2 years ago

In that case, the desired file should be /home/rstudio/.config/rstudio/rstudio-prefs.json.

By the way, that version of the rocker image issue is not tracked in this repository, but in https://github.com/rocker-org/rocker-versioned2. Please check the README.

ATpoint commented 2 years ago

Sorry for posting in the wrong repo. The answer that works for me was to copy a user-settings file like

$ cat user-settings
save_workspace="never"
always_save_history="false"
reuse_sessions_for_project_links="true"
restore_source_documents="false"
wrap_tab_navigation="false"
load_workspace="false"
initial_working_directory="~"
restore_last_project="false"
editor_theme="Idle Fingers"
soft_wrap_rmd_files="false"
rmd_chunk_output_inline="false"
auto_run_setup_chunk="false"
hide_console_on_chunk_execute="false"
posix_terminal_shell="bash"

...into /home/rstudio/.rstudio/monitored/user-settings/ with a Dockerfile like:

$ cat Dockerfile
FROM rocker/rstudio:4.1.2
COPY user-settings /home/rstudio/.rstudio/monitored/user-settings/user-settings

which then makes RStudio use these settings. Thanks for your time!