RStudio version 1.3+
RStudio versions 1.3+ use/home/ubuntu/.config/rstudio/rstudio-prefs.json to store user preferences. You can use a pre run script in a custom compute environment to modify this file to launch RStudio with custom preferences. To learn more about the schema of rstudio-prefs.json, see RStudio’s official documentation on Customizing Session Settings.
Method 1: Write lines to settings file
If you know how to manually add configuration lines to therstudio-prefs.json settings file, you can write it in the pre run script. For example:
Method 2: Copy a saved settings file
Use this method to copy the settings from an existing RStudio session. This method is useful if you aren’t familiar with the syntax ofrstudio-prefs.json, or if you want to use preferences from an existing preference file.
- Run a session and modify the RStudio preferences as needed.
-
Before you stop the session, use the following R code to copy the
rstudio-prefs.jsonfile to the root of your project directory. -
Add the following lines to the pre run script of your environment definition to load the preferences file (if it exists) on subsequent runs:
RStudio version 1.2 and lower
Older versions (1.2 and lower) of RStudio use/home/ubuntu/.rstudio/monitored/user-settings/user-settings to store user preferences. 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:Method 2: Copy a saved settings file
Use this method to copy the settings from an existing RStudio session. This method is useful if you aren’t familiar with the syntax ofrstudio-prefs.json, or if you want to use preferences from an existing preference file.
- Run a session and modify the RStudio preferences as needed.
-
Before you stop the session, use the following R code to copy the
user-settingsfile to the root of your project directory. -
Add the following lines to the pre-setup script of your environment definition to load the preferences file (if it exists) on subsequent runs:
The
sed statement that deletes the initialWorkingDirectory variable ensures that your session starts with the correct working directory.