前言
因为安装某些软件,需要用到devtools
,但是很可惜,直接在WSL的ubuntu 18.04中,我的R的版本是R version 3.6.1 (2019-07-05)
,无论使用非sudo用户或者sudo用户安装,都失败了:
sudo R --no-save
install.packages("devtools", repos="http://cran.r-project.org", clean=TRUE)
## ERROR: dependencies ‘usethis’, ‘callr’, ‘desc’, ‘pkgbuild’, ‘pkgload’, ‘rcmdcheck’, ‘roxygen2’, ‘rversions’, ‘testthat’ are not available for package ‘devtools’
## mv: cannot move '/home/luna/R/x86_64-pc-linux-gnu-library/3.6/00LOCK-ps/00new/ps' to '/home/luna/R/x86_64-pc-linux-gnu-library/3.6/ps': Permission denied
安装过程中,一直出现这些错误,实在没办法了,google了一下。
解决
因为R 3.6的一个新的功能,所以会出现这些问题,这个功能的名字是staged installation of packages
; 个人感觉这个新功能主要面对的可能是R包的作者或者维护者,对于安装人员好像造成了一些困扰。
这个新功能的介绍中解释了00new
文件夹的意义:
The current implementation of package installation by default backs up the old installation of the package by moving it into a per-library 00LOCK directory (or per-package 00LOCK-pkgname). The installation is performed directly into the final directory pkgname in the library. If it fails, it is by default cleaned up and the old version is moved back; otherwise, if it succeeds, the old version is deleted. If the lock directory already exists when the installation is requested, the installation fails with an error and one typically would delete the directory manually. During parallel install, the per package locking is used (00LOCK-pkgname).
This locking mechanism works for backing-up and recovering previous versions of packages in case of error, but it does not prevent access to partially installed packages
可以取消这个功能,在R中:
Sys.setenv(R_INSTALL_STAGED = FALSE)
install.packages("devtools", repos="http://cran.r-project.org", clean=TRUE)
参考
staged installation of packages
“Non Zero Exit Status” R 3.6.0 "Biobase"
—— dulunar 后记于 2019.11
网友评论