事情的起因是这样的,我想在R Studio中安装github中的包,执行了以下代码:
install.packages("devtools", dependencies = TRUE, type = "binary")
library(devtools)
install_github('yuabrahamliu/eClock')
然后就报下方错误:
installation of package
‘C:/Users/Admin/AppData/Local/Temp/RtmpMJDqM2/file93420cd3b9d/eClock_1.0.0.tar.gz’
had non-zero exit status
之前也遇到过类似错误’…had non-zero exit status’,解决办法参考了https://zhuanlan.zhihu.com/p/438451509,对于CRAN包真的有解决,但这个有些不大一样,也就是加上 type=“binary” 也还是报错。
于是我开始了解决之路,首先尝试了不同的R语言安装github包的方法,参考https://blog.csdn.net/tandelin/article/details/103634548,然鹅,三种方法(1,2,4)都尝试了还是不行!
我继续针对之前的报错信息进行解决,有一条错误是这么提示的:
ERROR: dependencies ‘AnnotationDbi’,
‘IlluminaHumanMethylation450kanno.ilmn12.hg19’, ‘bumphunter’,
‘org.Hs.eg.db’, ‘TxDb.Hsapiens.UCSC.hg19.knownGene’,
‘GenomicFeatures’, ‘GenomicRanges’, ‘IRanges’ are not available for
package ‘eClock’
* removing ‘G:/Program Files/R/R-4.2.1/library/eClock’
我先是尝试安装缺失的依赖包,发现安装不了,报错信息如下:
> install.packages("AnnotationDbi", dependencies = TRUE, type = "binary")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Warning in install.packages :
package ‘AnnotationDbi’ is not available as a binary package for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
> install.packages("AnnotationDbi", dependencies = TRUE)
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Warning in install.packages :
package ‘AnnotationDbi’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
根据提示信息‘package ‘AnnotationDbi’ is not available as a binary package for this version of R’,我想是不是R版本的问题,于是,我换用了不同的R版本,前前后后,安装了五个!R-3.6.3, R-4.2.1, R-4.0.2, R-4.1.0, R-4.1.3,这个问题仍没解决。
最开始使用的是R-3.6.3,错误提示’eClock 要求R版本>=4.0.2’;
于是我下载安装了R-4.2.1, 报的错误就是上方的依赖包 are not available错误;
以为是版本问题,又下载安装了R-4.0.2,报错提示‘devtools是用R版本4.0.5来建造的’;
又下载安装了R-4.1.0,报错提示‘devtools是用R版本4.1.3来建造的’;
我忽然理解了之前提示的R-4.0.5,于是又下载安装了R-4.1.3,
但是,仍然报了和之前同样的错误,即:
ERROR: dependencies ‘AnnotationDbi’,
‘IlluminaHumanMethylation450kanno.ilmn12.hg19’, ‘bumphunter’,
‘org.Hs.eg.db’, ‘TxDb.Hsapiens.UCSC.hg19.knownGene’,
‘GenomicFeatures’, ‘GenomicRanges’, ‘IRanges’ are not available for
package ‘eClock’
* removing 'G:/Program Files/R/R-4.1.3/library/eClock
又仔细看了install.packages(“AnnotationDbi”, dependencies = TRUE)的报错信息,里面有提到Rtools,于是去https://cran.rstudio.com/bin/windows/Rtools/下载安装了rtools40-x86_64.exe,再次安装‘AnnotationDbi’仍然报同样错误,并且程序似乎没有找到Rtools,仍然显示:
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:>
https://cran.rstudio.com/bin/windows/Rtools/
猜测可能是没有重启Rstudio,之后重启试试,再就是根据提示信息来这看看https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages。
重启之后,再安装‘AnnotationDbi’果然没有报Rtools的错误了,但仍然提示:
Warning in install.packages :
package ‘AnnotationDbi’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
看来接下来只能在上面提示的网址中找找解决办法了。
通过阅读,了解到了Install Packages的相关内容,部分如下:
搜索发现,AnnotationDbi在Bioconductor库中,https://bioconductor.org/packages/release/bioc/html/AnnotationDbi.html,使用如下安装方法,即可安装成功。
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("AnnotationDbi")
由于之前的报错信息说环境缺少多个依赖包,于是统统安装:
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install(c('AnnotationDbi', 'IlluminaHumanMethylation450kanno.ilmn12.hg19', 'bumphunter',
'org.Hs.eg.db', 'TxDb.Hsapiens.UCSC.hg19.knownGene', 'GenomicFeatures',
'GenomicRanges', 'IRanges'))
之后再运行代码,我所需要的包终于安装成功了!!!
library(devtools)
install_github('yuabrahamliu/eClock')
害,太不容易了,终于搞定了,我想下次再遇到‘…had non-zero exit status.‘的R包安装失败问题,我能够有方向性的解决了,这就是收获吧!下面总结一下,如果你在安装某个R包时采用install.packages(“pkgname”)也遇到了‘…had non-zero exit status.‘这种情况,可以先从以下方面进行解决:
如果上述方法皆不能解决,要认真阅读报错信息,根据提示信息进行检查和调整,也可以浏览https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages获得更多信息。
最后,希望大家的问题都可以得到解决!