rstudio / packrat

Packrat is a dependency management system for R
http://rstudio.github.io/packrat/
401 stars 89 forks source link

Error about "file exists" when opening a project #609

Open bioteamMichael opened 4 years ago

bioteamMichael commented 4 years ago

I just updated R via homebrew, and now when I launch the RStudio IDE on my mac and open an existing project I get

Warning message:
In file.symlink(from, to) :
  cannot symlink '/usr/local/Cellar/r/4.0.2_1/lib/R/library/base' to '/Users/mike/src/work/gRED/packrat/lib-R/x86_64-apple-darwin19.5.0/4.0.2/base', reason 'File exists'

I'm assuming that this is something with the update to R, since the symlink exists but points to the old version of R I had:

$ ls -l /Users/mike/src/work/gRED/packrat/lib-R/x86_64-apple-darwin19.5.0/4.0.2/base
lrwxr-xr-x 1 mike staff 44 Jun 23 21:58 /Users/mike/src/work/gRED/packrat/lib-R/x86_64-apple-darwin19.5.0/4.0.2/base -> /usr/local/Cellar/r/4.0.2/lib/R/library/base

Running packrat::restore() didn't seem to help out any.

bioteamMichael commented 4 years ago

Quitting RStudio, deleting all the symlinks in ~/src/work/gRED/packrat/lib-R/x86_64-apple-darwin19.5.0/4.0.2, and then relaunching caused everything to be relinked correctly, but I'd be curious to know why that happened.

Could it be because homebrew provided an updated build of 4.0.2?

kevinushey commented 4 years ago

That seems possible. Packrat is supposed to be able to refresh those symlinks on demand as required.

https://github.com/rstudio/packrat/blob/5173a3faea677b7b7f5ad46f6bbcbeabaef3e688/R/library-support.R#L3-L33 https://github.com/rstudio/packrat/blob/5173a3faea677b7b7f5ad46f6bbcbeabaef3e688/R/library-support.R#L72-L118

Regardless, the right way to "fix" this is to delete the old symlinks so that Packrat can refresh them, or to simply disable sandboxing altogether (if you don't need to rely on the system library being sandboxed).