lo labs
lo labs

Reputation: 139

Why are objects masked after running library(renv) in R?

I'm following this steps, like in this workflow here:

  1. renv::init()
  2. working as usual and installing new packages
  3. renv::snapshot()

The problem I'm facing is while running library(renv), many functions are been masked, like load, so I have to re-mask them all over my code in order to make it work again. Like base::load(...) Is there a way to avoid this masking?

Here the logs while running library(renv):

> 
> Attaching package: ‘renv’
> 
> The following object is masked from ‘package:stats’:
> 
>     update
> 
> The following objects are masked from ‘package:utils’:
> 
>     history, upgrade
> 
> The following objects are masked from ‘package:base’:
> 
>     load, remove

Upvotes: 1

Views: 103

Answers (2)

Kevin Ushey
Kevin Ushey

Reputation: 21285

renv is designed with the expectation that users will normally always use the renv:: prefix when referring to its functions; e.g.

renv::install()

For that reason, you normally shouldn't load renv via library(), and instead should use it via that prefix (unless you want to manage conflicts on the search path).

If you still want to load renv as a regular R package, I would recommend using:

library(renv, include.only = <...>)

to ensure only the functions you want on the search path are placed there.

Upvotes: 1

polkas
polkas

Reputation: 4184

As I understand the exclude argument might solve your problem. like:

library(renv, exclude = c("load", "update"))

More secure will be to use methods directly for such conflicts by ::.

Upvotes: 0

Related Questions