尝试在MacOS的R中安装devtools时退出状态为非零

时间:2019-07-08 10:55:48

标签: r macos package devtools

我一直在尝试在MacOS的R中安装devtools,首先是在RStudio中使用

install.packages("devtools")

然后用作替代:

install.packages("devtools",lib="/usr/local/Cellar/r/3.6.0_3/lib/R/library")

这给了权限错误,因此我使用了终端:

sudo R

然后使用与RStudio中相同的命令来安装软件包,这给我两个命令带来了以下错误:

1: In install.packages("devtools", lib = "/usr/local/Cellar/r/3.6.0_3/lib/R/library") :
  installation of package ‘xml2’ had non-zero exit status

2: In install.packages("devtools", lib = "/usr/local/Cellar/r/3.6.0_3/lib/R/library") :
  installation of package ‘roxygen2’ had non-zero exit status

3: In install.packages("devtools", lib = "/usr/local/Cellar/r/3.6.0_3/lib/R/library") :
  installation of package ‘devtools’ had non-zero exit status

我没有使用R的经验,并且在使用Ubunu或CentOS时在线提到的解决方案不起作用。

如果您对如何安装devtools以及导致这些错误的原因有任何建议,请告诉我,我们非常感谢任何建议。 预先谢谢你!

使用dependencies = TRUE可以进行更多的安装,但仍会得到以下结果:

The downloaded source packages are in
    ‘/private/tmp/RtmptCt93z/downloaded_packages’
Warning messages:
1: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘xml2’ had non-zero exit status

2: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘RCurl’ had non-zero exit status

3: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘rvest’ had non-zero exit status

4: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘roxygen2’ had non-zero exit status

5: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘rversions’ had non-zero exit status

6: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘spelling’ had non-zero exit status

7: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘rsconnect’ had non-zero exit status

8: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘foghorn’ had non-zero exit status

9: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘devtools’ had non-zero exit status

10: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘pkgdown’ had non-zero exit status

我尝试将RStudio中显示的路径手动添加到我的.bash_profile中,这导致我的终端不再知道任何命令(sudo,nano等),这可能是正确的方式来解决问题?

> R.home()
[1] "/usr/local/Cellar/r/3.6.0_3/lib/R"

1 个答案:

答案 0 :(得分:1)

我终于通过直接通过https://cran.r-project.org/web/packages/devtools/devtools.pdf下载devtools来解决了这个问题(由@NelsonGon建议)

然后将该文件夹移动到R.home()/ library

然后在终端中使用sudo运行devtools以安装github软件包。