full manual package install without admin privledges

I am using r and RStudio at work, I do not have full admin privileges for my machine, but I can manually move (copy paste) files from one folder to another. I can download a package .zip, but the install process in R and via RStudio wants to automatically move the unpacked file from one system folder to another. The problem is that I get the following error/warning :

package ‘vcd’ successfully unpacked and MD5 sums checked
Warning in install.packages :
unable to move temporary installation ‘C:\Apps\R-3.4.3\R-3.4.3\library\file3f837c424bc_{package_name}’ to ‘C:\Apps\R-3.4.3\R-3.4.3\library_{package_name}

Is there a way to do the complete install and file moves manually or any other process that will result in a functional package.

This might actually be an issue with your antivirus not having enough time to check the file before it is moved. Try telling R to pause for a minute when installing before moving the file over

run this code:

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

Then go down to about line 140, you should see the following:

ret <- unlink(instPath, recursive = TRUE, force = TRUE)
      if (ret == 0) {
        Sys.sleep(0.5)

change the number in Sys.sleep from 0.5 to 2. For a huge package maybe do 3, but I've found almost everything works if you tell it to wait 2 seconds.

Note, this will reset the next time you restart your R session, so you will need to do it again.

Note - you still have to make sure you have access to write to the file where your packages are kept, but based on your post, it seems that you do. If you find out that you can't write to that directory, you can change where your r packages are kept - but that can be more annoying.

1 Like

Thank you so much for this, it worked! This saves me all the hassle I was going to have to face against IT to give me special permissions if there was no other way. Thanks again.

Know that this issue with R has been fixed in R > 3.5.0

file.rename has evolved to take care of Antivirus issue
See comment

file.rename automatically retries few times if necessary
due to anti-virus interference

Sys.sleep is no more present in last versions.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.