问题
I am trying to install Bioconductor into R, using the code on their website. When I type in the code (see bellow) I get an error message saying that some packages can't be updated, the installation path is unwriteable.
> ## 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 these package by going to packages/install 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
I can then go to packages/ load packages and load them succesfully and search and see that the 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 bioconductor it gives me the same error message that Matrix, mgcv and survival aren't able to 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 be able to update these packages so I can install bioconductor?
回答1:
It was a permission issue for me. First, I identified where the packages were installed using installed.packages()[, c("Package", "LibPath")]
. This outputs a long 2 column matrix with the names and locations of the packages. Then you will see where the offending packages are. In my case, they were at /usr/lib/R/site-library
and /usr/lib/R/library
. Then I changed the permission of these folders by chmod
(I used chmod -R 777
on the main R folder, this is my personal computer, so security is not a big concern here I think).
回答2:
Like Martin Morgan answered, the Bioconductor packages should have been installed despite the error messages. However, this continues to occur when making future package updates.
In general, I would advise against changing permission of systems folders, as programs like R should work well without administrative right.
If you avoid changing permissions of system folders, I would likewise advice 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!
The best way to solve this, is to reinstall packages that have previously been installed with administrative rights. The packages can be identified from the error code produced by Bioconductor. In your case these packages are Matrix, mgcv, survival
- note that the error message does not distinct between CRAN and Bioconductor packages, it includes all packages that have previously been installed with administrative rights!
To remove the reported packages, open R with administrative rights (for the last time hopefully) and use remove.packages()
to remove all of the reported packages - including Bioconductor packages. For your case:
remove.packages(c("Matrix", "mgcv", "survival"))
Before reinstalling these packages, exit and then restart R without adminstrative rights. You can now reinstall the CRAN packages.
install.packages(c("Matrix", "mgcv", "survival"))
You will be asked whether you want to install the packages at a local directory, type yes
to that.
In case the installation will not succeed, locate you local R directory (in your home
/user
folder) and add it as the lib =
. On linux, the command could look like this:
install.packages(c("Matrix", "mgcv", "survival"), lib = "~/R/x86_64-pc-linux-gnu-library/3.5")
If Bioconductor packages have previously been installed with administrative rights:
library(BiocInstaller)
biocLite(c("PACKAGE1", "PACKAGE2"))
Again add the lib =
argument to the biocLite()
commnad, if otherwise unable to install in the local directory.
回答3:
It looks like several 'recommended' packages are installed in two places -- maybe by an administrator account in a directory you don't have write access to, and then by RStudio in a directory where you do have write access. biocLite()
is complaining about the former.
Unless biocLite()
complains about a Bioconductor package that cannot be installed (different from cannot be updated), there is no problem and basic Bioconductor packages have been successfully installed. Check out https://support.bioconductor.org for future Bioconductor-related support.
回答4:
One solution is to open a terminal and load R using admin rights
sudo R
update.packages()
source("https://bioconductor.org/biocLite.R")
biocLite()
Then you can update. But careful. This can create packages by the admin in a directory supposed to be owned by a user.
In this case, instead of loading R as root (which is solving the problem until the next update), check the .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 packages in "/usr/lib/R/library" are owned by root, and all except one are owned by a normal user (not root) at "/home/itsame/R/x86_64-pc-linux-gnu-library/3.4".
If you have admin rights, an easy solution may be to run chown in all the places: For example, I had trouble 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/
回答5:
If you are running R/Rstudio on Windows, then just open R/Rstudio as administrator. Right click on the icon then run as administrator
回答6:
Since with the version of R 3.6.1 the script http://bioconductor.org/biocLite.R returns this message " Error: With R version 3.5 or greater, install Bioconductor packages using BiocManager; see https://bioconductor.org/install " I solved the problem with the following steps:
- Get the list of directories used by R to install libraries and
choose the one with write permissions using:
.libPaths()
- Installing the "BiocManager" library using:
install.packages("BiocManager")
- Installation of the library "bioconductor" by forcing the directory
with write permissions using:
BiocManager::install("Rgraphviz", lib = "C:/Users/tizbet/Documents/R/win-library/3.6")
I worked on the following R installation:
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 Kasper Thystrup Karstensen answer
回答7:
I had same problem, and the answer is to give Root Access to R i.e run R or Rstudio as administrator.
check this question out: installed directory not writable, cannot update packages 'boot', 'class', 'KernSmooth', 'mgcv', 'nnet', 'rpart', 'spatial'
回答8:
Correct way to resolve this problem is as followed:
- Start R as an administrator:
sudo R
- In R console execute this:
update.packages()
Summary is, some latest packages are required and updating those on admin mode solve this issue. `
来源:https://stackoverflow.com/questions/41839214/installation-path-not-writable-r-unable-to-update-packages