Problem with package installation

Good morning. I have a problem when installing new packages, something that didn't happen before. This is the example of the psych package in a Rmarkdown:

install.packages("psych")

library(psych)

Response:
Installing package into ‘/opt/R/4.0.3/lib/R/library_shared’
(as ‘lib’ is unspecified)
Warning in install.packages :
'lib = "/opt/R/4.0.3/lib/R/library_shared"' is not writable

The background jobs says the following:
Show in new window
Installing the package in '/opt/R/4.0.3/lib/R/library_shared' (since 'lib' is not specified).
(since 'lib' is not specified)
Warning in install.packages :
'lib = "/opt/R/4.0.3/lib/R/library_shared"' is not writable.
Installing 'psych' ...
Installing the package in '/opt/R/4.0.3/lib/R/library_shared' (since 'lib' is not writable)
(since 'lib' is not specified)
Warning in utils::install.packages("psych", repos = "https://cran.rstudio/") :
lib = "/opt/R/4.0.3/lib/R/library_shared"' not writable
Error in utils::install.packages("psych", repos = "https://cran.rstudio.com/") :
can't install packages
Callback: sourceWithProgress -> eval -> eval ->
Interrupted execution

I'm having a really hard time finding a solution.

You don't have write permissions on this folder, either change your user's permissions accordingly or set set your package library in a folder where you have write permissions.

You can change the default library folder by setting your R_LIBS_SITE environmental variable in a .Reviron or .Rprofile file. For example:

# In a .Renviron file you can set it by adding a line like this one with the desired location 
R_LIBS_SITE="C:\\Program Files\\R\\R-4.1.2\\library"

For a more detailed explanation, you can read this blog post

It is now solved. Thank you very much for your time and great explanation. See you soon.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.