R包安装失败并出现“ had non-zero exit status”报错解决办法

问题描述:
R包安装中出现诸如“non-zero exit status”情况的报错信息,
虽然退出R后再library中手动删除R包,但是仍然无法奏效。
笔者参考以下两篇文章问题得以解决。
installation of package ‘blob’ had non-zero exit status
R install.packages returns “failed to create lock directory”

问题报错

install.packages("backports")

There is a binary version available but the source version is later:
binary source needs_compilation
backports  1.1.7  1.1.8              TRUE

installing the source package ‘backports’

试开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/backports_1.1.8.tar.gz'
Content type 'application/x-gzip' length 18047 bytes (17 KB)
downloaded 17 KB

ERROR: failed to lock directory 'C:/software/R/R-4.0.2/library' for modifying
Try removing 'C:/software/R/R-4.0.2/library/00LOCK-backports'
Warning in install.packages :
installation of package ‘backports’ had non-zero exit status

解决方法:

This happens when your last package installation has interrupted abnormally. to fix this you should remove the locked file. For example Execute this command in R console(删除这个lock的文件):

意思就是上一次安装被异常打断了,为了解决这个问题,必须要手动删除这个locked文件。

unlink("C:/software/R/R-4.0.2/library/00LOCK-backports", recursive = TRUE).
install.packages("backports")
The downloaded source packages are in   ‘C:\Users\Administrator\AppData\Local\Temp\RtmpoX81A2\downloaded_packages’

你可能感兴趣的:(R包安装失败并出现“ had non-zero exit status”报错解决办法)