rubuntuwindows-10windows-subsystem-for-linux

R package 'ps' fails to install because permission denied to mv in final step of install


I'm trying to install R: devtools, and a single dependency (ps) is failing to install, cascading into lack of dependencies. I'm using WSL Ubuntu on Windows 10, R 3.6, and the current RStudio version.

It fails in all situations (using RStudio, accessing through command prompt, starting all the above in admin mode, starting R using sudo). I've also tried turning off my firewall as suggested by other questions around similar issues. Finally, I've tried installing it to other .libPaths() locations. Other packages install just fine. I haven't tried installing from source- because I'd need devtools to do so.

Based on the error messages, the command mv does not have permission to move the installed package from its temporary install directory to the final location in my package library (but the installation utility has no trouble making directories or writing files). Anyone have any ideas why this could happen with just this single package? I'm baffled.

> install.packages('ps')
Installing package into ‘/usr/lib/R/library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/ps_1.3.0.tar.gz'
Content type 'application/x-gzip' length 261887 bytes (255 KB)
==================================================
downloaded 255 KB
* installing *source* package ‘ps’ ...
** package ‘ps’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -g -O2 -fdebug-prefix-map=/build/r-base-VjHo9C/r-base-3.6.0=. - fstack-protector-strong -Wformat -Werror=format-security -Wdate-time - D_FORTIFY_SOURCE=2 -g  -Wall px.c -o px

a bunch of other code that I am too no0b to understand

gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o ps.so init.o api-common.o common.o extra.o dummy.o posix.o api-posix.o linux.o api-linux.o -L/usr/lib/R/lib -lR
installing via 'install.libs.R' to /usr/lib/R/library/00LOCK-ps/00new/ps
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
mv: cannot move '/usr/lib/R/library/00LOCK-ps/00new/ps' to
'/usr/lib/R/library/ps': Permission denied
ERROR:   moving to final location failed
The downloaded source packages are in
‘/tmp/Rtmpm7SpMt/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("ps") :
installation of package ‘ps’ had non-zero exit status

Solution

  • Setting this before installing ps solved in my WSL ubuntu 18.04.2 LTS with R 3.6.0 on Windows 10 Pro. May help your case.

    Sys.setenv(R_INSTALL_STAGED = FALSE)
    

    https://developer.r-project.org/Blog/public/2019/02/14/staged-install/

    “Non Zero Exit Status” R 3.6.0 "Biobase"