I've found a number of questions related to this warning when installing or updating packages in R/RStudio, but none seem to completely match my situation:
C:\Users\[myname]\R
C\Users\[myname]\RStudio
R_LIBS_USER
added as user environment variable, pointing to right directory.libPaths()
show correct directories, both system and usertrace(utils:::unpackPkgZip,edit = T)
and edited Line 140 Sys.sleep(0.5)
to Sys.sleep(2)
, which sometimes works temporarily but the edit won't stay put... resets to Sys.sleep(0.5)
on every session restartAny package larger than a few Kb gives the message:
package ‘packagename’ successfully unpacked and MD5 sums checked
Warning in install.packages :
unable to move temporary installation ‘C:\Users\[myname]\R\win-library\3.4\file2b884fc37c13\packagename’ to ‘C:\Users\[myname]\R\win-library\3.4\packagename’
The packages are failing to install or update. So, my questions are:
unpackPkgZip
to save permanently?At this point, I'm stumped. I suspect it has something to do with the antivirus temporarily locking the file/directory after download, but I can't do anything about it from that end. The Sys.sleep(2)
seems to do the trick, but I can't keep doing that before every package install or update and can't seem to get the edit to stay put.
This was the only thing that worked for me on this issue (the uninstalling antivirus software didn't get me anywhere, unfortunately), so hopeful it works for you.
On Windows systems, sometimes installation of libraries may be running too fast, creating the error "unable to move temporary installation". Then the package is not found in the user library, because it hasn't been moved over...
To fix, try: trace(utils:::unpackPkgZip, edit=TRUE)
Then go to Line 140 in the code and change Sys.sleep(0.5)
to Sys.sleep(2.5)
This is a nice longer term solution that does not require manual package moving, uninstalling software, replacing admin responsibilities, or individually routing packages to certain locations.