Warning in install.packages: unable to move temporary installation

Scard picture Scard · Oct 5, 2017 · Viewed 31.4k times · Source

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:

  • Corporate Windows 7 system, so no access to admin privileges
  • No way to make changes to McAfee Anti-Virus exceptions lists
  • R is fully installed in the user space C:\Users\[myname]\R
  • RStudio fully installed in userspace C\Users\[myname]\RStudio
  • no permission issues in either of the directories... I have full access control over them
  • Problem only started after installing R 3.4, but RStudio has randomly failing at start or hanging for a few months now
  • R_LIBS_USER added as user environment variable, pointing to right directory
  • .libPaths() show correct directories, both system and user
  • R version 3.4.2, RStudio version 1.0.153
  • Uninstalled both R and Rstudio and did a clean re-install of both
  • Tried trace(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 restart
  • Happens in both RStudio and RGui
  • Any 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:

  1. is there a way to avoid the problem altogether that doesn't require admin privileges or changes to the antivirus policies?
  2. is there a way to get the edit to 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.

Answer

kslayerr picture kslayerr · Mar 6, 2018

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.