Errors updating packages: Failed to lock directory for modifying/Permission Denied: related to .dll?

I am having a problem where I cannot update any packages using R studio. I will use the package "backports" as an example but I have been getting this with many package updates.

This is the error I get when using install.packages("backports"):

ERROR: failed to lock directory 'D:/Program Files/R/win-library/3.6' for modifying
Try removing 'D:/Program Files/R/win-library/3.6/00LOCK-backports'
Warning in install.packages :
  installation of package ‘backports’ had non-zero exit status

And this the error when using BiocManager::install("backports"):

Warning: cannot remove prior installation of package 'backports'
Warning: restored ‘backports’
Warning messages:
1: In file.copy(savedcopy, lib, recursive = TRUE) :
  problem copying D:\Program Files\R\win-library\3.6\00LOCK\backports\libs\x64\backports.dll to D:\Program Files\R\win-library\3.6\backports\libs\x64\backports.dll: Permission denied

One thing I have noticed is that all the files that get these copying errors generated by BiocManager are .dll files. Could this be something to do with it?

Things I have tried:

  • Running Rstudio as an administrator
  • Moving my library to another location
  • Fiddling with permissions on folders

The only thing I can do to update is to delete the folder from the library manually but this is getting annoying.
Thanks in advance for any help.

Have you tried this?

Yeah this does work as I mentioned in my post, it's just getting annoying to have to find and delete a package from the library every time I want to update something. (sorry I just accidently deleted the previous message saying the same thing)

Strange that it's happening to you very frequently. Usually it results from an improperly terminated package installation so you should generally see this problem only when you re-attempt installation of the same package.

One thing you could try is installing to your personal library rather than the common library as it is currently set. That would definitely rule out any permissions-related issues.

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