The installation path is not writable by R, packages cannot be updated

I am trying to install Bioconductor in R using the code on my website. When I enter the code (see below), I get an error message stating that some packages cannot be updated, the installation path is unacceptable.

> ## try http:// if https:// URLs are not supported > source("https://bioconductor.org/biocLite.R") Bioconductor version 3.4 (BiocInstaller 1.24.0), ?biocLite for help > biocLite() BioC_mirror: https://bioconductor.org Using Bioconductor 3.4 (BiocInstaller 1.24.0), R 3.3.2 (2016-10-31). installation path not writeable, unable to update packages: Matrix, mgcv, 

survival

I can install this package by going to packages / installation packages.

 > utils:::menuInstallPkgs() trying URL 'https://www.stats.bris.ac.uk/R/bin/windows/contrib/3.3/Matrix_1.2-8.zip' Content type 'application/zip' length 2775038 bytes (2.6 MB) downloaded 2.6 MB trying URL 'https://www.stats.bris.ac.uk/R/bin/windows/contrib/3.3/mgcv_1.8- 16.zip' Content type 'application/zip' length 2346257 bytes (2.2 MB) downloaded 2.2 MB trying URL 'https://www.stats.bris.ac.uk/R/bin/windows/contrib/3.3/survival_2.40-1.zip' Content type 'application/zip' length 5109948 bytes (4.9 MB) downloaded 4.9 MB package 'Matrix' successfully unpacked and MD5 sums checked package 'mgcv' successfully unpacked and MD5 sums checked package 'survival' successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\stxeb8\AppData\Local\Temp\Rtmp2tQZ4v\downloaded_packages 

Then I can go to the packages / downloads and download them successfully and search and see what packages are there.

 > local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) Loading required package: nlme This is mgcv 1.8-16. For overview type 'help("mgcv-package")'. > local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) > local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) > local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) > search() [1] ".GlobalEnv" "package:survival" "package:mgcv" [4] "package:nlme" "package:Matrix" "package:BiocInstaller" [7] "package:stats" "package:graphics" "package:grDevices" [10] "package:utils" "package:datasets" "package:methods" [13] "Autoloads" "package:base" 

But then, when I go to install the bioconductor, it gives me the same error message that Matrix, mgcv and survival cannot be updated.

 > ## try http:// if https:// URLs are not supported > source("https://bioconductor.org/biocLite.R") Bioconductor version 3.4 (BiocInstaller 1.24.0), ?biocLite for help > biocLite() BioC_mirror: https://bioconductor.org Using Bioconductor 3.4 (BiocInstaller 1.24.0), R 3.3.2 (2016-10-31). installation path not writeable, unable to update packages: Matrix, mgcv, survival 

What can I do to update these packages to install the bioconductor?

+18
source share
8 answers

It was a permission issue for me. First, I determined where the packages were installed using installed.packages()[, c("Package", "LibPath")] . This outputs a long matrix of 2 columns with package names and locations. Then you will see where the abusive packages are. In my case, they were in /usr/lib/R/site-library and /usr/lib/R/library . Then I changed the permissions for these folders using chmod (I used chmod -R 777 in the main folder R, this is my personal computer, so security is not a big problem here, I think).

+14
source

As Martin Morgan replied, Bioconductor packages should have been installed despite error messages. However, this continues to happen with future package updates.

In general, I would advise you not to change the permission of the system folders, since programs such as R should work well without administrative rights.

If you avoid changing the permissions of system folders, I would also advise against installing packages using administrative rights, since you will have to do this in the future every time you have to update these packages!

The best way to solve this problem is to reinstall previously installed packages with administrator rights. Packets can be identified by the error code issued by Bioconductor. In your case, these are the packages Matrix, mgcv, survival - note that the error message does not differ between CRAN and Bioconductor packages, it includes all packages that were previously installed with administrator rights!

To remove reported packages, open R with administrator privileges (hopefully for the last time) and use remove.packages() to remove all reported packages, including Bioconductor packages. For your case:

 remove.packages(c("Matrix", "mgcv", "survival")) 

Before reinstalling these packages, exit and restart R without administrator privileges . Now you can reinstall the CRAN packages.

 install.packages(c("Matrix", "mgcv", "survival")) 

You will be asked if you want to install packages in a local directory, enter yes to do this.

If the installation failed, find your local R directory (in the home / user folder) and add it as lib = . On Linux, a command might look like this:

 install.packages(c("Matrix", "mgcv", "survival"), lib = "~/R/x86_64-pc-linux-gnu-library/3.5") 

If Bioconductor packages were previously installed with administrator rights:

 library(BiocInstaller) biocLite(c("PACKAGE1", "PACKAGE2")) 

Add the lib = argument again to the biocLite() , if otherwise it cannot be installed in the local directory.

+8
source

It seems that several “recommended” packages are installed in two places - perhaps with an administrator account in a directory that you do not have write access to, and then RStudio in a directory where you have write access. biocLite() complains about the first.

If biocLite() does not complain about the Bioconductor package that cannot be installed (different from the one that cannot be updated), there are no problems, and the basic Bioconductor packages were successfully installed. Check out https://support.bioconductor.org for future support related to Bioconductor.

+2
source

One solution is to open a terminal and load R using administrator rights

 sudo R update.packages() source("https://bioconductor.org/biocLite.R") biocLite() 

Then you can upgrade. But be careful. This can create packages by the administrator in the directory that should belong to the user.

In this case, instead of loading R as root (which solves the problem until the next update), check .libPaths (). You will have a list of directories.

 .libPaths() "/home/it_s_me/R/x86_64-pc-linux-gnu-library/3.4" "/usr/lib/R/library" 

In my case, all the packages in "/ usr / lib / R / library" belong to root, and all but one belong to ordinary users (not root) in "/ home / itsame / R / x86_64- PC-Linux-gnu-library / 3.4 ".

If you have administrator rights, a simple solution could be to run in all places: for example, I had problems updating the curl package. I used:

 sudo chown -R it_s_me /home/it_s_me/R/x86_64-pc-linux-gnu-library/3.4/curl/ 
0
source

If you use R / Rstudio on Windows, just open R / Rstudio as an administrator. Right-click the icon, then run as administrator.

0
source

Since in version R 3.6.1, the script http://bioconductor.org/biocLite.R returns this message "Error: for version R 3.5 or higher, install Bioconductor packages using BiocManager; see https://bioconductor.org/install " . I solved the problem with the following steps:

  1. Get a list of directories used by R to install the libraries and select the one that has write permissions using: .libPaths()
  2. Installing the BiocManager library with: install.packages("BiocManager")
  3. Installing the Bioconductor library by forcing a directory with write permissions using: BiocManager::install("Rgraphviz", lib = "C:/Users/tizbet/Documents/R/win-library/3.6")

I worked on the following installation of R:

platform x86_64-w64-mingw32 , arch x86_64 , os mingw32 , system x86_64, mingw32 , version.string R version 3.6.1 (2019-07-05)

I was inspired by the answer of Casper Tistrup Carstensen

0
source

I had the same problem and the answer is to provide Root Access for R ie, run R or Rstudio as an administrator .

check this question: the installed directory is not writable, cannot update the packages 'boot', 'class', 'KernSmooth', 'mgcv', 'nnet', 'rpart', 'spaces'

-1
source

The correct way to solve this problem is as follows:

  1. Run R as administrator: sudo R
  2. In the R console, do this: update.packages()

In short, some recent packages are required, and updating in administrator mode solves this problem. ''

-1
source

Source: https://habr.com/ru/post/1263285/


All Articles