【发布时间】:2019-11-17 21:07:04
【问题描述】:
我一直在尝试在 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"
【问题讨论】:
-
安装过程中会发生什么?还显示了哪些其他消息?您是否尝试将依赖项设置为 TRUE(
install.packages("devtools",dependencies=TRUE)) 进行安装? -
@NelsonGon,谢谢你的建议,我已经粘贴了在我的问题中作为编辑给出的 reslt(评论太长了)
-
我认为这与缺少编译器和/或必要的编译器包有关。不是 OSX 用户,但我认为运行它可能会有所帮助:
brew install libsvg curl libxml2 gdal geos boost。另见:rud.is/b/2015/10/22/installing-r-on-os-x-100-homebrew-edition 更详细的帖子:stackoverflow.com/questions/20923209/… -
@NelsonGon,在运行您的最后一个建议后,我仍然遇到同样的问题,也许我需要在我的 .bash_profile 中添加路径(R?)?我试图弄清楚如何以及哪一个,有什么建议吗?
-
我认为这不是 R 本身的问题,请先尝试安装:thecoatlessprofessor.com/programming/…