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

Custom location of renv/library folder #384

Closed
rpahl opened this issue Apr 9, 2020 · 5 comments
Closed

Custom location of renv/library folder #384

rpahl opened this issue Apr 9, 2020 · 5 comments

Comments

@rpahl
Copy link

rpahl commented Apr 9, 2020

First of, nice package!

I am trying to use renv in combination with package development (under Windows) to share package configurations among developers, but due to the renv/library folder, commands like

  • R CMD build
  • R CMD check

are taking very long probably due to scanning of all the renv/libraries. That is, adding the renv directory to the .Rbuildignore file does not seem to prevent R from still scanning it.

As a workaround, I can clone my git repo (which does not contain renv/library) somewhere else to check & build it. So to save this step, renv would require an option to put the renv/library folder somewhere else, e.g. just outside the package root.
Sorry, if that is already possible, but I could not find anything in the docs to make renv work like this.

Thanks!
Roman

@rpahl rpahl changed the title Custom location of renv folder Custom location of renv/library folder Apr 9, 2020
@kevinushey
Copy link
Collaborator

kevinushey commented Apr 9, 2020

Indeed -- unfortunately, R CMD build first copies the entire package folder to a temporary directory, then checks based on that. Copying is of course slow with the renv folder embedded.

A workaround is to tell renv to use a non-local library path; e.g. in a project .Renviron:

RENV_PATHS_LIBRARY = ~/.renv/library/<package>

replacing <package> with the name of your package as appropriate.

I'm still considering whether I could do something like this by default for package projects, since this is going to be a common pain point for anyone using renv and developing a package at the same time.

@Pit-Storm
Copy link

Pit-Storm commented Jun 17, 2020

@kevinushey I have a question to clearify the Path reference of renv. there is written:

Note that renv will append platform-specific and version-specific entries to the set paths as appropriate.

For my understanding the RENV_PATHS_LIBRARY path don't get any expandation with version or system specific extensions, because this directory could contain packages already. Is this right?

To ask the question in more advanced way: If I set the env var RENV_PATHS_LIBRARY this variable is valid for every environment not just one?

It would be great if you can specifiy more clearly in which scope every env variable is considered and valid.

Thank you and kind regards :-)

@kevinushey
Copy link
Collaborator

For my understanding the RENV_PATHS_LIBRARY path don't get any expandation with version or system specific extensions, because this directory could contain packages already. Is this right?

Sorry, I should make this more clear -- renv will always append the architecture + OS to the library path set by RENV_PATHS_LIBRARY.

We do this so that the user can set a single RENV_PATHS_LIBRARY path, that can then be used across different systems / R versions without worry that you might end up using an "incompatible" library.

Let me know if that's the behavior you were hoping for, or were hoping for a mechanism to avoid appending the architecture-specific path components.

@kevinushey
Copy link
Collaborator

I think the right solution here is for renv to place the library paths within something like:

tools:::R_user_dir("renv", which = "data")

I'll try to explore this.

@kevinushey
Copy link
Collaborator

This has now been implemented in the development version of renv. If you start renv in a package project, you should see something like:

> .libPaths()
[1] "/Users/kevin/Library/Caches/org.R-project.R/R/renv/library/renv-b932b8a8/R-4.1/aarch64-apple-darwin20.6.0"
[2] "/private/var/folders/9n/3nxsgkrj0rlfx196kzdttpww0000gn/T/Rtmph3UzgU/renv-system-library"

If you want the old behavior, you can use:

RENV_PATHS_LIBRARY = renv/library

in an appropriate .Renviron file. See vignette("packages", package = "renv") for more details.

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

No branches or pull requests

3 participants