Was trying to install some packages using the install.packages() command and was facing some strange issue with below error.
Warning: unable to move temporary installation 'C:\Oracle\R-3.4.2\library\file6cae3bcf\MASS' to 'C:\Oracle\R-3.4.2\library\MASS'
Warning: unable to move temporary installation 'C:\Oracle\R-3.4.2\library\file6cae3bcf\MASS' to 'C:\Oracle\R-3.4.2\library\MASS'
Warning: unable to move temporary installation 'C:\Oracle\R-3.4.2\library\file6cae3bcf\MASS' to 'C:\Oracle\R-3.4.2\library\MASS'
Initially I was considering the permissions problem so i tried running the install.packages() command from cmd line as an administrator. Also gave full control on R installation directory to all users. Nothing worked.
Finally I was able to find solution from some random function mentioned R documentation. What actually is happening is that R is trying to install the mentioned package but is also interrupting it, interesting right.
Lets see in detail, when an install.packages() command is executed R will download the package to temp space, extract it and then place it in library path. But the extracting and copying are performed very closely that they are practically happening at the same time. All I had to do was insert some lag between them, otherwise put R to sleep for sometime.
Which can be performed using Sys.sleep(time) command, the default value used in "unpackPkgZip" utility which is used to extract the downloaded packages is 0.5 sec, we will increase it to may be 2.5 or 3 etc. as follows.
The below command will open the unpackPkgZip utility code in edit mode
trace(utils:::unpackPkgZip, edit=TRUE)
Go to Sys.sleep(0.5) and replace it with 2.5 and save.
Now run the install.packages("MASS") which should run with out any errors.
This comment has been removed by the author.
ReplyDeleteThank you.
ReplyDelete