This is a test version of Biostars. For the public version, visit https://www.biostars.org.
no permission to install to directory

Hello. I am a graduate student, and I am trying to analyze using R server through the infrastructure server provided by my school.

When I try to install an R package, an error occurs: ‘Error: ERROR: no permission to install to directory ‘/usr/lib/R/library’’. Does anyone know why this error occurs?

One more thing: R is also installed on the laptop I use.

Thank you for your help!

r

sooni : You asked many questions over the last few months but seem to have never validated any answers (upvote or accept using green check mark). See here

Please consider doing so. Validating answers makes them useful for future visitors and is the appropriate means of appreciating (free) help you get on biostars.

1 answer

currently your R is using the global binary (probably in /usr/bin/R), which will attempt by default to install libraries into /usr/lib/R/library. These directories are generally not modifiable except under very rare circumstances.

The .libPaths function (https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/libPaths) allows you to change where R looks for and installs packages, e.g., if you set

dir.create("/home/sooni/Rlib")
.libPaths("/home/sooni/Rlib")

will use the local Rlib directory (that you just made) to build and install packages. More generally from the documentation:

The library search path is initialized at startup from the environment variable R_LIBS

so using

export R_LIBS=/home/sooni/Rlib

before running R will instruct R to use your local directory (note that /home/sooni/Rlib must actually exist for this to work).

Log in to answer this question.