I concur with @Deb. This is annoying. And the responses as well. It is common practice even in a non-shared system (private computer) to run all commmands as a standard non-privileged user, and install software packages using sudo.
In a fresh system (Ubuntu), to install the base R you will have to use sudo. In my case, for the specific R packages I need, I have to install also some dev packages as follows:
sudo apt install r-base
sudo apt install build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev
sudo apt install libfontconfig1-dev libharfbuzz-dev libfribidi-dev
sudo apt install libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
Then, even if following all tutorials about using private R libs, e.g. in my case:
export R_LIBS_USER="/home/fernan/R/x86_64-pc-linux-gnu-library/4.4"
running R as myself without sudo, and trying to install packages would work most of the time (e.g. install.packages("devtools")
, install.packages("BiocManager")
) but frustratingly, then something like this would happen in the very same R session:
> BiocManager::install(c("Biostrings", "rtracklayer"))
'getOption("repos")' replaces Bioconductor standard repositories, see
'help("repositories", package = "BiocManager")' for details.
Replacement repositories:
CRAN: https://cloud.r-project.org
Bioconductor version 3.20 (BiocManager 1.30.25), R 4.4.2 (2024-10-31)
Installing package(s) 'Biostrings', 'rtracklayer'
trying URL 'https://bioconductor.org/packages/3.20/bioc/src/contrib/Biostrings_2.74.1.tar.gz'
Content type 'application/x-gzip' length 12823307 bytes (12.2 MB)
==================================================
downloaded 12.2 MB
trying URL 'https://bioconductor.org/packages/3.20/bioc/src/contrib/rtracklayer_1.66.0.tar.gz'
Content type 'application/x-gzip' length 4112666 bytes (3.9 MB)
==================================================
downloaded 3.9 MB
* installing *source* package âBiostringsâ ...
** package âBiostringsâ successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C compiler: âgcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0â
gcc -I"/usr/share/R/include" -DNDEBUG -I'/home/fernan/R/x86_64-pc-linux-gnu-library/4.4/S4Vectors/include' -I'/home/fernan/R/x86_64-pc-linux-gnu-library/4.4/IRanges/include' -I'/home/fernan/R/x86_64-pc-linux-gnu-library/4.4/XVector/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-LHi8Yy/r-base-4.4.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c BAB_class.c -o BAB_class.o
[...]
[... chunks ommitted for clarity ...]
[...]
installing to /home/fernan/R/x86_64-pc-linux-gnu-library/4.4/00LOCK-Biostrings/00new/Biostrings/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
in method for âtwoWayAlphabetFrequencyByQualityâ with signature â"QualityScaledXStringSet"â: no definition for class âQualityScaledXStringSetâ
Creating a new generic function for âstrsplitâ in package âBiostringsâ
Creating a generic function for âlsâ from package âbaseâ in package âBiostringsâ
Creating a new generic function for âpatternâ in package âBiostringsâ
Creating a new generic function for âoffsetâ in package âBiostringsâ
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (Biostrings)
* installing *source* package ârtracklayerâ ...
** package ârtracklayerâ successfully unpacked and MD5 sums checked
** using staged installation
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for OPENSSL... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C compiler: âgcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0â
gcc -I"/usr/share/R/include" -DNDEBUG -DUSE_SSL -D_FILE_OFFSET_BITS=64 -I'/home/fernan/R/x86_64-pc-linux-gnu-library/4.4/S4Vectors/include' -I'/home/fernan/R/x86_64-pc-linux-gnu-library/4.4/IRanges/include' -I'/home/fernan/R/x86_64-pc-linux-gnu-library/4.4/XVector/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-LHi8Yy/r-base-4.4.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c S4Vectors_stubs.c -o S4Vectors_stubs.o
gcc -I"/usr/share/R/include" -DNDEBUG -DUSE_SSL -D_FILE_OFFSET_BITS=64 -I'/home/fernan/R/x86_64-pc-linux-gnu-library/4.4/S4Vectors/include' -I'/home/fernan/R/x86_64-pc-linux-gnu-library/4.4/IRanges/include' -I'/home/fernan/R/x86_64-pc-linux-gnu-library/4.4/XVector/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-LHi8Yy/r-base-4.4.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c IRanges_stubs.c -o IRanges_stubs.o
[...]
[... chunks ommitted for clarity ...]
[...]
** R
** data
** demo
** inst
** byte-compile and prepare package for lazy loading
Creating a generic function for âoffsetâ from package âstatsâ in package ârtracklayerâ
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rtracklayer)
The downloaded source packages are in
â/tmp/RtmpXhTi2g/downloaded_packagesâ
Installation paths not writeable, unable to update packages
path: /usr/lib/R/library
packages:
codetools, lattice, spatial
Why is R not using R_LIBS_USER???
Can someone help out here? Much appreciated.