Warning in install.packages: unable to move temporary installation

后端 未结 11 2451
孤城傲影
孤城傲影 2020-12-05 05:00

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:

  • Co
相关标签:
11条回答
  • 2020-12-05 05:10

    My original reply is below, but I've subsequently found a better solution.

    Execute the following line:

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

    Note that there three colons in there, not two.

    Then edit line 142, from Sys.sleep(0.5) to: Sys.sleep(2.0), and click to save the edit (the line number may vary slightly). Unfortunately this does not hold across R sessions, but it only takes 10 seconds to do this, and then you can install packages for the current session to your heart's content.

    Original answer:

    I ran into the same problem at work. I was able to use Sheldon's suggested approach, but as noted that can get tedious quickly. As an alternative, I found I could go to the location of the downloaded zip file(s) in my temp directory (as reported by install.packages), unzip the file or files (there will be multiple zip files if there are dependent packages), and then move or copy all the unzipped directories straight into my R\win-library\3.4 directory. This isn't a whole lot of fun either, but I find it to be less painful than stepping through the debugger, per Sheldon's method, especially when multiple dependencies are involved and also have to be installed.

    0 讨论(0)
  • 2020-12-05 05:11

    If you cannot turn off your antivirus here is a workaround that I found that doesn't involve editing the unpackPkgZip file. Debugging the unzip package function and then stepping through it gives the antivirus enough time to do its job without interfering. Use this command:

    debug(utils:::unpackPkgZip) install.packages("packageName")

    and then step through the code (by pressing enter many times) when R starts debugging during the installation.

    I found this solution here.

    If you want to make this change more permanent you can add the debug code into your Rprofile file, see here, but you'll still need to use step through the unzip function each time a package is installed.

    0 讨论(0)
  • 2020-12-05 05:13

    I also found one solution if above solutions wouldn't work in corporate antivirus. First change the path of package installation use this command and execute in R:

    install.packages('caTools','D:\\ML\\Tools\\Installed\\RPackages')
    

    Now it will show a console's error that unable to move and the package is placed on to some location. just remember this location, we need this zip file for further operations.

    Now use this command:

    install.packages("D:/ML/Tools/Installed/RPackages/caTools_1.17.1.zip", repos = NULL, type = "win.binary", lib="D:/ML/Tools/Installed/R-3.4.3/library") 
    
    0 讨论(0)
  • 2020-12-05 05:14

    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.

    0 讨论(0)
  • 2020-12-05 05:15

    If you run the below statement right before the install.packages expression then it should install the package:

    trace("unpackPkgZip", where=asNamespace("utils"), quote(Sys.sleep(2.5)), at=14L, print=FALSE)
    
    0 讨论(0)
  • 2020-12-05 05:20

    We've had the same problem at my workplace, and one of my coworkers discovered a great workaround. Unfortunately it's a temporary thing you'll need to do each time you install packages, rather than a permanent fix. We're running corporate Windows 8 (no admin privileges) with McAfee, and I've tested this in R 3.4.0-3.4.3.

    Temporarily turning off McAfee's "On-Access Scan" feature (in Threat Prevention) solved this for us -- R packages now all install on the first try the way they're intended to. Here's detailed steps to turn that off:

    1. Right-click the McAfee icon in the notification area at the right of your taskbar, and select McAfee Endpoint Security.
    2. Click on Threat Prevention. This opens up a screen where you should see categories such as "Access Protection", "Exploit Prevention", and "On-Access Scan".
    3. Un-check "Enable On-Access Scan", and then click Apply. (NB: it's easy to forget to click Apply, but it's essential)

    Once you've installed your packages, it's best to repeat the process to turn On-Access Scan back on.

    0 讨论(0)
提交回复
热议问题