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.
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()
andstartup::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 whatgetwd()
reports.This should also be agile to any
R_ENVIRON
,R_ENVIRON_USER
,R_PROFILE
, andR_PROFILE_USER
settings.There could also be a
startup::disable(once = TRUE)
, which will automatically callstartup::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 toR --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 emulateR --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.