rrenv

Is it possible for `renv` to be "bypassed" or temporarily turned off?


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?

Solution

  • 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:

    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().