我在安装R软件包devtools时遇到了这个问题。我的R工作室在Anaconda,它是最新版本。代码是这样的:
install.packages("devtools")
我得到的答复如下:
also installing the dependency ‘git2r’
trying URL 'https://cran.rstudio.com/src/contrib/git2r_0.21.0.tar.gz'
Content type 'application/x-gzip' length 1155512 bytes (1.1 MB)
==================================================
downloaded 1.1 MB
trying URL 'https://cran.rstudio.com/src/contrib/devtools_1.13.5.tar.gz'
Content type 'application/x-gzip' length 486555 bytes (475 KB)
==================================================
downloaded 475 KB
* installing *source* package ‘git2r’ ...
** package ‘git2r’ successfully unpacked and MD5 sums checked
checking build system type... x86_64-apple-darwin17.6.0
checking host system type... x86_64-apple-darwin17.6.0
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/private/var/folders/mh/df2k68vs4g3714qyztvg2y980000gn/T/RtmppuLmjL/R.INSTALL8f6b17805a/git2r':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘git2r’
* removing ‘/Users/nora/anaconda3/lib/R/library/git2r’
Warning in install.packages :
installation of package ‘git2r’ had non-zero exit status
ERROR: dependency ‘git2r’ is not available for package ‘devtools’
* removing ‘/Users/nora/anaconda3/lib/R/library/devtools’
Warning in install.packages :
installation of package ‘devtools’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/mh/df2k68vs4g3714qyztvg2y980000gn/T/Rtmpyjv9BV/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
为了解决这个问题,我尝试了以下但没有改变:
现在我已在终端中使用此代码安装此软件包:
conda install -c r r-devtools
当我在R控制台中输入install.packages("devtools")
时,似乎没有任何错误,我看到反馈如下:
trying URL 'https://cran.rstudio.com/src/contrib/devtools_1.13.5.tar.gz'
Content type 'application/x-gzip' length 486555 bytes (475 KB)
==================================================
downloaded 475 KB
* installing *source* package ‘devtools’ ...
** package ‘devtools’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (devtools)
The downloaded source packages are in
‘/private/var/folders/mh/df2k68vs4g3714qyztvg2y980000gn/T/Rtmpyjv9BV/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
但我不确定我是否还有C编译器问题。如果是这样,我仍然希望解决这个问题,以便将来方便。而且,我不知道为什么我首先要解决这个问题。