Closed adamrobinson361 closed 5 years ago
Am I right in thinking that changing the cacheLibDir function from :
function (...)
{
file.path(appDataDir(), packratCacheVersion(), "library",
...)
}
to
function (...)
{
file.path(appDataDir(), paste0(R.Version()$major, ".", R.Version()$minor), packratCacheVersion(), "library",
...)
}
Would solve this problem?
If so are you happy with me pull requesting this change?
Adam
This would be the correct sort of change but I'm a bit wary of changing a default like this since it would effectively strip an existing Packrat cache out from underneath users by default.
That said, the fact that an existing Packrat cache can break after upgrading R is definitely bad and probably warrants a change like this.
Agreed that when an update occurs this is a break waiting to happen suggesting a change is best.
I'm not clear the cache code so far in packrat that you can actually tell what version of R it was installed under so there could be some cashes that are already mixed. This would suggest to me that a fresh start is necessary to avoid any big changes?
I wouldn't think this would be too much of a problem for users as the cache is more of a convenience feature rather than something to rely on I would think? That said no doubt some of the cache wouldn't rebuild for some users for packages now requiring compilation and not having installed the right libraries similar to renv::equip().
@kevinushey - just following up on this with two questions.
You can have installation-specific environment variables by making use of Rprofile.site
or Renviron.site
. For example, the system Renviron.site
would be located at:
file.path(R.home("etc"), "Renviron.site")
Note that this file doesn't exist by default; you may have to create and edit it manually.
Regardless, I would welcome a PR but we'd have to confirm that it doesn't regress any of the other machinery we have that currently depends on Packrat.
Thanks Kevin - my second point was more around if you knew of if it was possible to set a dynamic environment variable r version specific using renviron vs rprofile.
e.g. PACKRAT_CACHE_DIR = C:/somedirectory/$RVersion
Thats perfectly possible in RProfile due to being able to being able to dynamically set the environment variable with sys.setenv but not sure how I'd do that without access to r code. I don't think there is an R Version environment variable.
I'll get on with submitting a pull request tomorrow,
Cheers,
Adam
Ah, sorry, I understand now. Unfortunately (to the best of my knowledge) there's nothing like that available.
@kevinushey - I'm trying to understand how I can set the R_PACKRAT_CACHE_DIR environment variable to be r version specific.
In my experience the packrat cache is r major version specific and you will get errors saying that a package has been built by a version of R with different internals if you just use one for multiple r versions on a system (system being widows for me).
I've been setting it dynamically in ".~/.Rprofile" but this is then overridden by the projects .Rprofile when I open projects using the .Rproj file. Are there any workarounds?