可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I wish to use the devtools
package. I've run the following commands:
> install.packages("devtools", dependencies = TRUE)
....
> library(devtools)
Error in library(devtools) : there is no package called ‘devtools’
What am I doing wrong?
Edit: Here are the results of re-running the install.packages
command after restarting the session.
> install.packages("devtools", dependencies = TRUE)
Installing package into ‘/home/evanaad/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Warning: dependencies ‘roxygen2’, ‘BiocInstaller’, ‘rstudio’ are not available
also installing the dependencies ‘httr’, ‘RCurl’
trying URL 'http://cran.at.r-project.org/src/contrib/httr_0.2.tar.gz'
Content type 'application/x-gzip' length 50183 bytes (49 Kb)
opened URL
==================================================
downloaded 49 Kb
trying URL 'http://cran.at.r-project.org/src/contrib/RCurl_1.95-4.1.tar.gz'
Content type 'application/x-gzip' length 870915 bytes (850 Kb)
opened URL
==================================================
downloaded 850 Kb
trying URL 'http://cran.at.r-project.org/src/contrib/devtools_1.4.1.tar.gz'
Content type 'application/x-gzip' length 105214 bytes (102 Kb)
opened URL
==================================================
downloaded 102 Kb
* installing *source* package ‘RCurl’ ...
** package ‘RCurl’ successfully unpacked and MD5 sums checked
checking for curl-config... no
Cannot find curl-config
ERROR: configuration failed for package ‘RCurl’
* removing ‘/home/evanaad/R/x86_64-pc-linux-gnu-library/3.0/RCurl’
ERROR: dependency ‘RCurl’ is not available for package ‘httr’
* removing ‘/home/evanaad/R/x86_64-pc-linux-gnu-library/3.0/httr’
ERROR: dependencies ‘httr’, ‘RCurl’ are not available for package ‘devtools’
* removing ‘/home/evanaad/R/x86_64-pc-linux-gnu-library/3.0/devtools’
The downloaded source packages are in
‘/tmp/RtmptvmTrA/downloaded_packages’
Warning messages:
1: In install.packages("devtools", dependencies = TRUE) :
installation of package ‘RCurl’ had non-zero exit status
2: In install.packages("devtools", dependencies = TRUE) :
installation of package ‘httr’ had non-zero exit status
3: In install.packages("devtools", dependencies = TRUE) :
installation of package ‘devtools’ had non-zero exit status
回答1:
As per damienfrancois's suggestion, I installed libcurl4-gnutls-dev and the problem was solved.
EDIT (@dardisco)
In your shell:
apt-get -y build-dep libcurl4-gnutls-dev
apt-get -y install libcurl4-gnutls-dev
回答2:
If you are using Ubuntu/Linux:
sudo apt-get install libcurl4-openssl-dev libssl-dev
回答3:
In case if you are using CentOS:
Try:
sudo yum -y install libcurl libcurl-devel
回答4:
For ubuntu users, run this command in your terminal [Tested in UBUNTU 16.04]
sudo apt-get -y install libcurl4-openssl-dev
post this install libraries the way you usually do in R using
install.packages("package name")
回答5:
Nowadays (ubuntu 14.04) I need both:
$ sudo apt-get -y install libcurl4-gnutls-dev
$ sudo apt-get -y install libssl-dev
回答6:
For my Debian Jessie box, I also included:
sudo apt-get build-dep libxml2-dev
Hint: The r-tool console output is pretty verbose so I would check for any other dependencies.
Then, I finally got it:
> find_rtools()
[1] TRUE
回答7:
Best solution to solve this. I was searching the same problem. I spent 1 day and then I got solution. Now, It is well.
Check your R version in bash terminal if you are on Ubuntu or Linux.
R --version
then use these commands
sudo apt-get update
sudo apt-get upgrade
Now check the new version of R. Use this command
sudo apt-cache showpkg r-base
Now update the R only.
sudo apt-get install r-base
Now R will be updated and the error will be removed. Make sure to cd
the library path where you want to install the new package. This way in bash terminal. Try to create the R directory at home folder or it will be at the default. Locate this location for package ~/R/lib/ .
R
.libPaths("~/R/lib")
install.packages("devtools")
OR
install.packages("devtools", lib="~/R/lib")
回答8:
CentOS 7:
I had the libcurl and gnutls development packages installed already, but still got the "cannot load git2r.so" error when installing devtools in R. I had to "reinstall" them for it to work:
sudo yum reinstall gnutls-devel.x86_64
回答9:
I hit this issue with Ubuntu 18.04 and none of the previous answers solved it. Eventually I succeeded by installing devtools
with the package manager itself:
sudo apt install r-cran-devtools
回答10:
Centos 6.8
this work like charm for me
- install libcurl
$yum -y install libcurl libcurl-devel
- restart R Software
$rstudio-server verify-installation