domino logo
4.6
  • Tech Ecosystem
  • Deployment-wide Search
  • Get Started
  • Security and Credentials
  • Collaborate
  • Organizations
  • Projects
  • Domino Datasets
  • External Data
  • Workspaces
  • Environments
  • Executions
  • Model APIs
  • Publish
  • Model Monitoring
  • Notifications
  • Domino Command Line Interface (CLI)
  • Troubleshooting
  • Get Help
domino logo
About Domino
Domino Data LabKnowledge BaseData Science BlogTraining
User Guide
>
Workspaces
>
Create a Workspace
>
Set Custom Preferences for RStudio Workspaces

Set Custom Preferences for RStudio Workspaces

RStudio user preferences for your runs (such as theme) are stored in a file in /home/ubuntu/.rstudio/monitored/user-settings/user-settings. To launch RStudio with custom preferences, you can use the pre-setup script in a custom compute environment to modify this file.

Method 1: Write lines to settings file

If you know what to add to the settings file, you can write it in the pre-setup script. For example:

mkdir -p /home/ubuntu/.rstudio/monitored/user-settings/ <b class="conum">(1)</b>
echo 'uiPrefs={"theme" : "Mono Industrial"}' >> /home/ubuntu/ .rstudio/monitored/user-settings/user-settings <b class="conum">(2)</b>
chown -R ubuntu:ubuntu /home/ubuntu/.rstudio <b class="conum">(3)</b>
if [ -f .domino/launch-rstudio-server ]; then
    sed -i.bak 's# > ~/.rstudio/monitored/user-settings/user-settings# >> ~/.rstudio/monitored/user-settings/user-settings#' .domino/launch-rstudio-server <b class="conum">(4)</b>
    chown ubuntu:ubuntu .domino/launch-rstudio-server <b class="conum">(3)</b>
fi

The following describes what each line is doing:

  1. The mkdir statement creates the encompassing directory.

  2. The echo statement writes the theme to the file. If you prefer to store a file in your project, you can replace this with a copy operation (see the next method).

  3. The chown statements avoid a permissions error.

  4. The sed statement modifies a Domino script that would overwrite this settings file.

Method 2: Copy a saved settings file

Use this method if do not know what lines to add, or if you want to persist this settings file in your project.

  1. Run a session and modify the RStudio preferences as needed.

  2. Before you stop the session, use the following R code to copy the user-settings file to the root of your project directory.

    file.copy("/home/ubuntu/.rstudio/monitored/user-settings/user-settings", ".")
  3. Add the following lines to the pre-setup script of your environment definition to load the preferences file (if it exists) on subsequent runs:

    if [ -f user-settings ]; then
        mkdir -p /home/ubuntu/.rstudio/monitored/user-settings/
        cp user-settings /home/ubuntu/.rstudio/monitored/user-settings
        sed -i.bak '/initialWorkingDirectory=/d' /home/ubuntu/.rstudio/monitored/user-settings/user-settings
        chown -R ubuntu:ubuntu /home/ubuntu/.rstudio
        if [ -f .domino/launch-rstudio-server ]; then
            sed -i.bak 's# > ~/.rstudio/monitored/user-settings/user-settings# >> ~/.rstudio/monitored/user-settings/user-settings#' .domino/launch-rstudio-server
            chown ubuntu:ubuntu .domino/launch-rstudio-server
        fi
    fi
Note
Domino Data LabKnowledge BaseData Science BlogTraining
Copyright © 2022 Domino Data Lab. All rights reserved.