I've installed R (version 3.6.0) on my ubuntu 18.04 which I run on the windows subsystem WSL.

Now I'm having a problem to install some specific packages. For example xml2. When I run the command install.packages("xml2"), i get the following error:

mv: cannot move '/usr/local/lib/R/site-library/00LOCK-xml2/00new/xml2' to '/usr/local/lib/R/site-library/xml2': Permission denied
ERROR:   moving to final location failed

I guess there might be some way to give myself full permission for managing my own stuff, does anyone know how to get around this issue?

  • Why not use R for Windows? Alternately install R packages directly from the ppa. – user68186 Aug 3 '19 at 12:58
  • Since iirc the default version of R in the Ubuntu 18.04 repository is 3.4, please edit your question to include how you installed R 3.6.0 (from a PPA? from a 3rd party tarball?) – steeldriver Aug 3 '19 at 13:28

This solution suggested on stackoverflow.com worked for me.

The best way to avoid this is to use the '--no-lock' argument on the command line, e.g.,

R CMD INSTALL --no-lock <pkg>

On NFS file systems it is sometimes not obvious what things you have to close. From within R, you can do this from within your command using:

install.packages("Rcpp", dependencies=TRUE, INSTALL_opts = c('--no-lock'))

Uninstall R version 3.6.0, and remove the R PPA if there is one from your software sources in /etc/apt/sources.list by preceding the line containing this PPA with a # character to turn it into a comment. Then run sudo apt update to refresh your list of available software. Now that you have removed the R packages that don't work, you are ready to install r-base and r-cran-xml2 from the default Ubuntu 18.04 repositories.

To install xml2 R package in Ubuntu 18.04 open the terminal and type:

sudo apt install r-base r-cran-xml2  

This GNU R XML parser package works with XML files using a simple, consistent interface. It's built on top of the 'libxml2' C library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.