Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 7, update.packages problem: "unable to move temporary installation"?

I am using R 2.13.0 with windows 7, after giving my user full privileges to the R folder (as described here). This allows me to install new packages just fine.

However, when using update.packages(), to update existing packages, I keep getting the following error (for example, when updating the MASS package):

package 'MASS' successfully unpacked and MD5 sums checked

Warning: unable to move temporary installation 'C:\Program Files\R\R-2.13.0\library\file6cae3bcf\MASS' to 'C:\Program Files\R\R-2.13.0\library\MASS'

Any suggestions on how to fix this?

p.s: Running R as an administrator or shifting the library location out of Program Files is not a solution (it's a hack - but I am looking for a solution)

like image 614
Tal Galili Avatar asked Apr 18 '11 08:04

Tal Galili


2 Answers

I found that the problem indeed is the antivirus "real time file system protection". I do the following to fix the problem:

trace(utils:::unpackPkgZip, edit=TRUE) 

I edit line 140 (line 142 in R 3.4.4):

Sys.sleep(0.5) 

to:

Sys.sleep(2) 

I seems like the antivirus stalls the creation of the package tmp dir. After changing it to 2 seconds the error is gone.

EDIT: to do this programmatically execute

trace(utils:::unpackPkgZip, quote(Sys.sleep(2)), at = which(grepl("Sys.sleep", body(utils:::unpackPkgZip), fixed = TRUE))) 

(credits @DavidArenburg)

like image 91
Mads Sønderkær Avatar answered Oct 13 '22 18:10

Mads Sønderkær


Just to update everyone, I (think that I) found out the source of the problem: antivirus.

The "real time file system protection" was blocking R from copying the files between folders once they were downloaded. Upon adding the R directory to the exception list (coupled with adding user permission and installing R on D:\R), and the problem went away. With all of this work, I might as well switch to Linux (I should, really...)

(I updated my post with the above information: http://www.r-statistics.com/2011/04/how-to-upgrade-r-on-windows-7/)

I hope it will help someone in the future, Tal

like image 25
Tal Galili Avatar answered Oct 13 '22 20:10

Tal Galili