11

I would like to export/import RStudio global options, which can typically found and set in RStudio at Tools> Global Options...

Ideally I could run a line of code, saving the existing settings to a file. Then run another line of code to load those settings from this file.

These options include settings such as a Dark Theme for the GUI, or Tab Width etc.

This has a range of uses but my specific use case is that I spin up virtual environments to utilize cloud computing. Each time I shutdown and/or spin-up a new environment I need to apply these various settings anew (or work with the defaults).

After searching for a while all I have found is this unanswered user request. Despite the unanswered request, I feel like there is/should be an existing way to do this, even if imperfect.

Thanks in advance for any help/direction

Dave
  • 410
  • 6
  • 13
  • 1
    After some further search I have found you can run options(), which gives a variety of global options but I'm not sure if this is the right direction? – Dave Jun 08 '18 at 13:33
  • options() seems to be for R's "internal" settings, so it's only indirectly related to RStudio. – Niki Herl May 07 '19 at 17:33

1 Answers1

4

Aha! I found a relevant support page: https://support.rstudio.com/hc/en-us/articles/200534577-Resetting-RStudio-Desktop-s-State

TL;DR:
Most settings are stored in a "RStudio-Desktop" folder. To be exact:

  • Windows: %localappdata%\RStudio-Desktop
    (fyi: %localappdata% usually resolves to C:\Users\{username}\AppData\Local [1])
  • Unix / MacOS: ~/.rstudio-desktop

I have confirmed that deleting/overriding that folder with a backup of it restores the settings from the time of the backup.

Some further information (e.g. last window size) may be stored at

  • Windows: %appdata%\RStudio
  • Unix: ~/.config/RStudio
    (I'm guessing it's the same for MacOS, but the relevant section is worded it bit weirdly, so I'm unsure.)
Niki Herl
  • 331
  • 3
  • 7
  • 1
    Thanks, the answer worked in my situation (Windows 10, 2 machines, RStudio 2021.09.2 Build 382). However, the second part was crucial to obtain the same "Appearance" (theme, font, etc.) as well as the same configuration in the "Packages", Management options (e.g. correct CRAN repo). – hyman Jan 19 '22 at 09:33
  • 1
    Note that this has changed since R version 1.3 https://support.rstudio.com/hc/en-us/articles/200534577-Resetting-RStudio-Desktop-s-State New location is `~/.local/share/rstudio` – JohnSG Sep 28 '22 at 18:32