If I'm following this correctly, it sounds like @bblake73's organization has been struggling with the phenomenon where install.packages()
can fail on Windows because antivirus software interferes with the step where an installed package binary is moved from a temporary directory to its final location. And the current workaround (as described in the answers to this StackOverflow question) is to overwrite a hard-coded Sys.sleep()
time, which of course is inconvenient, since this patch has to be applied anew each session. Have I got that right?
I think I can fill in some of the picture here. It looks like the Sys.sleep()
call in question was part of an unexported helper function called utils:::unpackPkgZip
. This helper function is only found in Windows-specific utils
code, since it's used by the internal function that installs package binaries on Windows.
The hard-coded Sys.sleep()
value was introduced back in the R 2.x era in an attempt to work around antivirus interference. However, as of R 3.5 (I think), a more sophisticated attempt to solve the antivirus problem was introduced. It was mentioned in this R-devel message, and this bit from the R 3.5.0 release notes seems to be related:
- On Windows,
file.rename()
internally retries the operation in case of error to attempt to recover from possible anti-virus interference.
This seems to be an area of ongoing development in the R core, with further refinements added recently (for the curious, see here and here).
TL;DR
Getting back to your question , @bblake73:
- The workaround involving patching
Sys.sleep()
will not work with R >= 3.5, since theSys.sleep()
call was replaced with a different approach to solving the antivirus interference problem - Hopefully the newer approach will work better! Are you able to test out updating to a newer version of R? I'd be curious to know whether you see any improvement in these package installation problems.
- This is all part of core R functionality, so I'm afraid it's not something that the RStudio IDE can directly affect. Decisions about how to make
install.packages()
handle antivirus interference better are up to the R Core Development Team.