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

issue with non-writable available package index #1171

Closed
hutch3232 opened this issue Mar 20, 2023 · 9 comments
Closed

issue with non-writable available package index #1171

hutch3232 opened this issue Mar 20, 2023 · 9 comments

Comments

@hutch3232
Copy link

Main issue:

renv::install("pkgname") hangs indefinitely on renv >= 0.17.0 due to my non-standard setup.

Details:

I have a large renv cache being used by many people. It's defined using the RENV_PATHS_ROOT environmental variable. That location is read-only* (for most users). For renv prior to 0.17.0 that would result in successful installs (simply a symlink) if the package existed in the cache and an error if it did not (because it can't write there).

Now, however, it seems to hang due to renv:::available_packages.

I found that if I run options(renv.index.enabled=FALSE) the old behavior is restored.

I'm wondering if there could be a solution where the index will automatically be used if it can succeed (maybe just a file.access test or something for write-ability) and disabled otherwise? Essentially to avoid having to specify this option in every project.

I realize this is probably a very uncommon setup so understand if this isn't worth it.

* The reason my setup is like this is because we have the renv cache mounted to Docker environments and for technical reasons the mounts need to be read-only. There is a separate process (where the cache is writable) to add new packages.

Thanks for the awesome package!

@kevinushey
Copy link
Collaborator

Thanks for the bug report! I want renv to work out-of-the-box in cases like yours as well so I'd like to consider if there's a better way for renv to handle this.

As a workaround, you could place the available packages index in a shared location, with something like:

RENV_PATHS_INDEX = <path/to/shared/writable/location>

And that could be added to your R installation's etc/Rprofile.site so it would be active for all R installations.

@kevinushey
Copy link
Collaborator

Perhaps the index could be placed in a location like this by default:

<renvRoot>/shared/<index>

And system administrators could allow that directory to be considered readable + writable by all users by default if desired?

@hutch3232
Copy link
Author

Thanks for these ideas! I tested the option of setting RENV_PATHS_INDEX to my /.../R proj/renv/index, where index is a new folder, and that worked well. I like this approach because it's presumably always going to be writeable. I'm guessing it's not the default because then others aren't getting to refer to it (even in cases where RENV_PATHS_ROOT is writeable. Setting the etc/Rprofile.site is a good idea too and might work for me.

@hutch3232
Copy link
Author

I haven't had a chance yet to test your fix yet 998c043 but I was also looking at my renv setup in a different environment where it is shared between many users and is also writeable (due to using RENV_CACHE_MODE) and I noticed the cached available packages .rds files are accumulating. I think the intent was to remove the old one when creating a new one, but in my case since someone else wrote the .rds file, I'm unable to remove it.

renv/R/index.R

Line 187 in e24dfb3

unlink(file.path(root, entry$data))

I wonder if the RENV_CACHE_MODE could be used to set the mode of the created .rds in a way similar to the tarballs under source/ and the packages under cache/.

@kevinushey
Copy link
Collaborator

Thanks for the heads up -- I'll take a look at that.

@kevinushey
Copy link
Collaborator

I think these commits should help:

9abe0db
1178600

Let me know if those make a difference.

@kevinushey
Copy link
Collaborator

(I think it should be okay to make these index files shared by default, rather than checking RENV_CACHE_MODE, but let me know if you disagree)

@hutch3232
Copy link
Author

Finally had a chance to test out these commits. Thank you for making these changes! It seems like this will work well and I like the approach taken.

@kevinushey
Copy link
Collaborator

Great to hear -- thank you!

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

2 participants