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?
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:
.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"
install.packages(c("PKG1", "PKG2", "PKG3"))
or BiocManager::install(c("PKG1", "PKG2", "PKG3"))
*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.