Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startup::disable()/enable(): Hide/unhide user's startup files #62

Open
HenrikBengtsson opened this issue Nov 16, 2018 · 0 comments
Open

Comments

@HenrikBengtsson
Copy link
Owner

HenrikBengtsson commented Nov 16, 2018

Background

There is no straightforward way to achieve R --vanilla when using RStudio Console - the only approach is to make sure to remove/hide all of ./.Rprofile, ~/.Rprofile, ./.Renviron, and ~/.Renviron (https://community.rstudio.com/t/how-to-do-an-r-vanilla-in-rstudio-console/13601).

Idea

Provide startup::disable() and startup::enable() that hides and unhides startup files from R by renaming them, e.g. to and from ~/.Rprofile.disabled_20181115-212105.

An alternative approach to renaming ~/.Rprofile, is to override it with an empty ./.Rprofile. (Note though that when doing 'Restart R' in the RStudio Console, RStudio used the original working directory from where it was started (defaults to ~) as the working directory, regardless of what getwd() reports.

This should also be agile to any R_ENVIRON, R_ENVIRON_USER, R_PROFILE, and R_PROFILE_USER settings.

There could also be a startup::disable(once = TRUE), which will automatically call startup::enable() the next time R is launched.

If a file cannot be renamed (e.g. due to lacking file privileges), a warning should be produced.

Result

With this, when restarting R / RStudio Console, we'll achieve R --no-init-file --no-environ. Compared to R --vanilla (= R --no-save --no-restore --no-site-file --no-init-file --no-environ), we still pick up site startup files (--no-site-file) and we still restore .RData (--no-restore) [Issue #42].

Limitations

Using startup::disable() will emulate R --vanilla for all future R sessions launched, not just the next one. Thus, one needs to be careful to use this in an environment where one run many R sessions in parallel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant