Trouble installing R Packages within WSL environment

Hello from Montreal!

I’m attempting to download AFNI onto my PC. Everything works except for R package installation.

With the following command: rPkgsInstall -pkgs ALL -site ‘http://cloud.r-project.org

I get the output:

Installing packages into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages(pkgs_miss, dep = NA, repos = site) :
‘lib = “/usr/local/lib/R/site-library”’ is not writable
Error in install.packages(pkgs_miss, dep = NA, repos = site) :
unable to install packages
Calls: getPkgs → install.packages
Execution halted

I’ve added write permissions to /usr/local/lib/R/site-library with: sudo chmod +w /usr/local/lib/R/site-library, though this did not solve the issue.

Is there any advice you can provide or any other information I can provide?

Try installing the packages inside R with the following command:

install.packages(c('afex', 'phia', 'snow', 'nlme', 'lmerTest', 'lme4'))

Be sure you have run:
export R_LIBS=$HOME/R

That will install the libraries into your ~/R directory, and will not require root access. It seems preferable to a root install (unless you are setting up a system for multiple users).

- rick

I tried on WSL 2, and it worked fine for me. Rick’s advice is good here, as usual. The settings for R installation are described in the AFNI installation documentation:

https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/background_install/install_instructs/steps_linux_ubuntu20.html#slow-setup-install-r