title: Warning in install.packages: unable to move temporary installation
body: <p>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:</p>
  
  <ul>
  <li>Corporate Windows 7 system, so no access to admin privileges</li>
  <li>No way to make changes to McAfee Anti-Virus exceptions lists</li>
  <li>R is fully installed in the user space <code>C:\Users\[myname]\R</code></li>
  <li>RStudio fully installed in userspace <code>C\Users\[myname]\RStudio</code></li>
  <li>no permission issues in either of the directories... I have full access control over them</li>
  <li>Problem only started after installing R 3.4, but RStudio has randomly failing at start or hanging for a few months now</li>
  <li><code>R_LIBS_USER</code> added as user environment variable, pointing to right directory</li>
  <li><code>.libPaths()</code> show correct directories, both system and user</li>
  <li>R version 3.4.2, RStudio version 1.0.153</li>
  <li>Uninstalled both R and Rstudio and did a clean re-install of both</li>
  <li>Tried <code>trace(utils:::unpackPkgZip,edit = T)</code> and edited Line 140 <code>Sys.sleep(0.5)</code> to <code>Sys.sleep(2)</code>, which sometimes works temporarily but the edit won't stay put... resets to <code>Sys.sleep(0.5)</code> on every session restart</li>
  <li>Happens in both RStudio and RGui</li>
  <li><p>Any package larger than a few Kb gives the message:</p>
  
  <pre><code>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’
  </code></pre></li>
  </ul>
  
  <p>The packages are failing to install or update. So, my questions are:</p>
  
  <ol>
  <li>is there a way to avoid the problem altogether that doesn't require admin privileges or changes to the antivirus policies?</li>
  <li>is there a way to get the edit to <code>unpackPkgZip</code> to save permanently?</li>
  </ol>
  
  <p>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 <code>Sys.sleep(2)</code> 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.</p>