I have an RStudio project that manages packages using renv
, which works great.
But sometimes I want to debug or explore something using libraries on my main environment(right word?) that I don't want to add to the project. For example, maybe I want to run some long debug function and call beepr::beep()
at the end. Is that possible without installing the beepr
package to the project?
long_process()
beepr::beep() # How do I make this call?
You could technically disable sandboxing, which is where renv
prevents packages installed in the system library from being made available in the project (which is why you wouldn't be able to use beepr::beep()
in your example. You can change your user configuration easily, just see the documentation from env. The setting here would be renv.config.sandbox.enabled
.
However, I don't think that's the best option. Depending on the snapshot type settings described in ?renv::snapshot
, you needn't worry about installing beepr
but it getting added to the lock file.
You can check or set the snapshot type using:
renv::settings$snapshot.type()
If you install the beepr
package in the environment, then depending on the type you will get:
"all"
: the only problematic setting. If you run snapshot with beepr
actively loaded, it will be added to the lock file, which isn't what you want.
"implicit"
: as long as beepr
isn't referenced in R code saved to the library, it won't be added to the lock file.
"explicit"
: only adds packages that are defined in DESCRIPTION
.
"custom"
: as implied, is custom, but depends on files saved in the project, so would only add beepr
if saved somewhere rather than just used interactively using debug.
So, in summary, unless you are using "all"
, you should be safe to install and use beepr
! If you are using "all"
, then just be sure to detach("package:beepr", unload = TRUE)
before running snapshot()
.