installation path not writable R, unable to update packages

In general, I would advise against changing the permission in system folders, because R should work without additional administrative rights.

Thus I would likewise advise against installing packages using administrative rights, as you would be required to do so in the future every time you have to update these packages!

To backtrace this issue and prevent to minimize it in future updates, you should perform the following steps:

  1. Note which packages that fail to update (already shown in the error message).
  2. Locate the folders where all R packages are installed using .libPaths(). This should provide two results, a destination in your home folder and a system folder.

“/home/USER/R/x86_64-pc-linux-gnu-library/X.X” “/usr/lib/R/library”

  1. Install the packages with install.packages(c("PKG1", "PKG2", "PKG3")) or BiocManager::install(c("PKG1", "PKG2", "PKG3"))*
  2. Only If you have administrator rights: Manually remove the older package folders from the system folder (“/usr/lib/R/library”), using administrator rights (sudo) OR enter R with administrator rights One last time and run remove.packages(c("PKG1", "PKG2", "PKG3"), lib = "/usr/lib/R/library").

*If there are issues with the installation path, add the argument , lib = "/home/USER/R/x86_64-pc-linux-gnu-library/X.X" to either of the install functions in step 3. This argument explicitly states to install in your home folder.

There is a single issue with this approach, at least with the official R repository on Arch Linux: Whenever R is updated, the updated version still includes packages in the system folder, that can’t be updated without administrative rights. Therefore for each R update, this procedure must be repeated. I’m especially looking at you survival!!!

*Edit: It is important to note that biocLite is no longer the recommended tool for installing BioConductor packages. You should instead use BiocManager, which is in the official CRAN repository (install.packages("BiocManager")).

**Second edit: As this answer still receives votes, I have updated and cleaned up the answer.

Leave a Comment