183

我想使用这个devtools包。我已经运行了以下命令:

> install.packages("devtools", dependencies = TRUE)
....
> library(devtools)
Error in library(devtools) : there is no package called ‘devtools’

我究竟做错了什么?

编辑:这是重新install.packages启动会话后重新运行命令的结果。

> 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
4

16 回答 16

201

根据damienfrancois的建议,我安装了 libcurl4-gnutls-dev 并解决了问题。

编辑(@dardisco)

在你的外壳中:

apt-get -y build-dep libcurl4-gnutls-dev
apt-get -y install libcurl4-gnutls-dev
于 2014-01-04T17:15:18.707 回答
107

如果您使用的是 Ubuntu/Linux:

sudo apt-get install libcurl4-openssl-dev libssl-dev
于 2016-08-01T11:56:49.407 回答
53

如果您使用的是 CentOS:

尝试:

sudo yum -y install libcurl libcurl-devel
于 2014-11-14T20:15:05.633 回答
14

我在 Ubuntu 18.04 中遇到了这个问题,之前的答案都没有解决它。最终我通过devtools包管理器本身安装成功:

sudo apt install r-cran-devtools

于 2019-04-11T07:12:00.313 回答
11

对于 ubuntu 用户,请在终端中运行此命令 [在 UBUNTU 16.04 中测试]

sudo apt-get -y install libcurl4-openssl-dev

以您通常在 R 中使用的方式发布此安装库

install.packages("package name")
于 2017-01-03T11:04:08.630 回答
10

对于我的 Debian Jessie 盒子,我还包括:

sudo apt-get build-dep libxml2-dev

提示:r-tool 控制台输出非常冗长,所以我会检查任何其他依赖项。

然后,我终于明白了:

> find_rtools()
[1] TRUE
于 2015-06-10T17:26:34.880 回答
10

我在窗户上,遇到了同样的问题。

我使用了以下代码:

install.packages("devtools", type = "win.binary")

然后 library(devtools) 为我工作。

于 2019-12-20T03:18:51.583 回答
10

如今(ubuntu 14.04)我需要两者:

 $ sudo apt-get -y install libcurl4-gnutls-dev
 $ sudo apt-get -y install libssl-dev
于 2016-09-01T04:05:52.393 回答
7

解决此问题的最佳解决方案。我正在寻找同样的问题。我花了1天,然后我得到了解决方案。现在,很好。

如果您使用的是 Ubuntu 或 Linux,请在 bash 终端中检查您的 R 版本。

R --version

然后使用这些命令

sudo apt-get update 
sudo apt-get upgrade              

现在检查 R 的新版本。使用这个命令

sudo apt-cache showpkg r-base

现在只更新 R。

sudo apt-get install r-base

现在 R 将被更新,错误将被删除。确保cd您要安装新软件包的库路径。这种方式在 bash 终端中。尝试在主文件夹中创建 R 目录,否则它将是默认值。找到包 ~/R/lib/ 的此位置。

R
.libPaths("~/R/lib")
install.packages("devtools")

或者

install.packages("devtools", lib="~/R/lib")
于 2015-10-07T12:55:31.183 回答
7

以上答案均不适用于使用R 版本 3.6.1的Ubuntu 18.04.3 LTS

我的猜测是这可能与Anaconda3...有关

对我有用的是:

conda install -c r r-devtools 

然后在R

install.packages("rlang")
install.packages("devtools")

sessionInfo()

R version 3.6.1 (2019-07-05)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS

Matrix products: default
BLAS/LAPACK: /home/tsundoku/anaconda3/lib/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8    
 [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8   
 [7] LC_PAPER=en_CA.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.6.1 tools_3.6.1    tcltk_3.6.1   
于 2019-11-05T18:54:18.557 回答
4

我解决了许多安装以下所有问题的问题,以便在 Ubuntu 18.04.1 上安装 devtools。

sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libssl-dev
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libxml2-dev
于 2019-11-11T16:14:43.850 回答
3

当我尝试安装 devtools 包时,我通过看到 R-Studio 的错误找到了解决方案......基本上错误是因为未在 linux 中安装依赖库查看下面的ANTICONF 错误

Installing package into ‘/home/hafiz/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependencies ‘curl’, ‘gh’, ‘openssl’, ‘xml2’, ‘usethis’, ‘covr’, ‘httr’, ‘roxygen2’, ‘rversions’


trying URL 'https://cloud.r-project.org/src/contrib/curl_4.3.tar.gz'
Content type 'application/x-gzip' length 673779 bytes (657 KB)
==================================================
downloaded 657 KB

trying URL 'https://cloud.r-project.org/src/contrib/gh_1.1.0.tar.gz'
Content type 'application/x-gzip' length 29043 bytes (28 KB)
==================================================
downloaded 28 KB

trying URL 'https://cloud.r-project.org/src/contrib/openssl_1.4.2.tar.gz'
Content type 'application/x-gzip' length 1204168 bytes (1.1 MB)
==================================================
downloaded 1.1 MB

trying URL 'https://cloud.r-project.org/src/contrib/xml2_1.3.2.tar.gz'
Content type 'application/x-gzip' length 271876 bytes (265 KB)
==================================================
downloaded 265 KB

trying URL 'https://cloud.r-project.org/src/contrib/usethis_1.6.1.tar.gz'
Content type 'application/x-gzip' length 255052 bytes (249 KB)
==================================================
downloaded 249 KB

trying URL 'https://cloud.r-project.org/src/contrib/covr_3.5.0.tar.gz'
Content type 'application/x-gzip' length 146148 bytes (142 KB)
==================================================
downloaded 142 KB

trying URL 'https://cloud.r-project.org/src/contrib/httr_1.4.2.tar.gz'
Content type 'application/x-gzip' length 159950 bytes (156 KB)
==================================================
downloaded 156 KB

trying URL 'https://cloud.r-project.org/src/contrib/roxygen2_7.1.1.tar.gz'
Content type 'application/x-gzip' length 254118 bytes (248 KB)
==================================================
downloaded 248 KB

trying URL 'https://cloud.r-project.org/src/contrib/rversions_2.0.2.tar.gz'
Content type 'application/x-gzip' length 41558 bytes (40 KB)
==================================================
downloaded 40 KB

trying URL 'https://cloud.r-project.org/src/contrib/devtools_2.3.1.tar.gz'
Content type 'application/x-gzip' length 373604 bytes (364 KB)
==================================================
downloaded 364 KB

* installing *source* package ‘curl’ ...
** package ‘curl’ successfully unpacked and MD5 sums checked
** using staged installation
Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcurl' found
Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcurl' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lcurl
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
  deb: **libcurl4-openssl-dev** (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fedora, CentOS, RHEL)
 * csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘curl’
* removing ‘/home/hafiz/R/x86_64-pc-linux-gnu-library/3.6/curl’
Warning in install.packages :
  installation of package ‘curl’ had non-zero exit status
* installing *source* package ‘openssl’ ...
** package ‘openssl’ successfully unpacked and MD5 sums checked
** using staged installation
Using PKG_CFLAGS=
--------------------------- [ANTICONF] --------------------------------
Configuration failed because openssl was not found. Try installing:
  deb: **libssl-dev** (Debian, Ubuntu, etc)
 * rpm: openssl-devel (Fedora, CentOS, RHEL)
 * csw: libssl_dev (Solaris)
 * brew: openssl@1.1 (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
tools/version.c:1:10: fatal error: openssl/opensslv.h: No such file or directory
    1 | #include <openssl/opensslv.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
--------------------------------------------------------------------
ERROR: configuration failed for package ‘openssl’
* removing ‘/home/hafiz/R/x86_64-pc-linux-gnu-library/3.6/openssl’
Warning in install.packages :
  installation of package ‘openssl’ had non-zero exit status
* installing *source* package ‘xml2’ ...
** package ‘xml2’ successfully unpacked and MD5 sums checked
** using staged installation
Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libxml-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libxml-2.0' found
Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libxml-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libxml-2.0' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lxml2
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libxml-2.0 was not found. Try installing:
 deb: **libxml2-dev** (Debian, Ubuntu, etc)
 * rpm: libxml2-devel (Fedora, CentOS, RHEL)
 * csw: libxml2_dev (Solaris)
If libxml-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libxml-2.0.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘xml2’
* removing ‘/home/hafiz/R/x86_64-pc-linux-gnu-library/3.6/xml2’
Warning in install.packages :
  installation of package ‘xml2’ had non-zero exit status
ERROR: dependencies ‘curl’, ‘openssl’ are not available for package ‘httr’
* removing ‘/home/hafiz/R/x86_64-pc-linux-gnu-library/3.6/httr’
Warning in install.packages :
  installation of package ‘httr’ had non-zero exit status
ERROR: dependency ‘xml2’ is not available for package ‘roxygen2’
* removing ‘/home/hafiz/R/x86_64-pc-linux-gnu-library/3.6/roxygen2’
Warning in install.packages :
  installation of package ‘roxygen2’ had non-zero exit status
ERROR: dependencies ‘curl’, ‘xml2’ are not available for package ‘rversions’
* removing ‘/home/hafiz/R/x86_64-pc-linux-gnu-library/3.6/rversions’
Warning in install.packages :
  installation of package ‘rversions’ had non-zero exit status
ERROR: dependency ‘httr’ is not available for package ‘gh’
* removing ‘/home/hafiz/R/x86_64-pc-linux-gnu-library/3.6/gh’
Warning in install.packages :
  installation of package ‘gh’ had non-zero exit status
ERROR: dependency ‘httr’ is not available for package ‘covr’
* removing ‘/home/hafiz/R/x86_64-pc-linux-gnu-library/3.6/covr’
Warning in install.packages :
  installation of package ‘covr’ had non-zero exit status
ERROR: dependencies ‘curl’, ‘gh’ are not available for package ‘usethis’
* removing ‘/home/hafiz/R/x86_64-pc-linux-gnu-library/3.6/usethis’
Warning in install.packages :
  installation of package ‘usethis’ had non-zero exit status
ERROR: dependencies ‘usethis’, ‘covr’, ‘httr’, ‘roxygen2’, ‘rversions’ are not available for package ‘devtools’
* removing ‘/home/hafiz/R/x86_64-pc-linux-gnu-library/3.6/devtools’
Warning in install.packages :
  installation of package ‘devtools’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmpexapon/downloaded_packages’

查看缺少 libssl-dev libxml2-dev 的粗体库

just you need to install these libraries in ubuntu terminal or

无论您使用什么操作系统,您都会发现操作系统相关的错误,请参阅详细错误信息。R-studio 提到了针对操作系统的相关库包名称

对于ubuntu,我这样做了

sudo apt-get install libssl-dev

**sudo apt-get install libxml2-dev **

sudo apt-get install libcurl4-openssl-dev

于 2020-08-29T22:53:25.223 回答
3

CentOS 7:我已经安装了 libcurl 和 gnutls 开发包,但是在 R 中安装 devtools 时仍然出现“无法加载 git2r.so”错误。我必须“重新安装”它们才能工作:

sudo yum reinstall gnutls-devel.x86_64
于 2016-08-05T19:43:40.220 回答
2

CentOS 7:

我在这篇文章中尝试了解决方案

sudo yum -y install libcurl libcurl-devel
sudo yum -y install openssl-devel

但还不够。

在控制台中检查 R 错误给了我答案。在我的情况下,它缺少下面的 libxml-2.0(并且控制台打印了一个带有包名称的解释到不同的 Linux 版本和其他可能的 R 配置)

sudo yum -y install libxml2-devel
于 2019-12-18T14:07:41.937 回答
1

对于 Ubuntu 18.0.4 上的 R 版本 4.0.2,我必须安装libgit2-dev软件包:

sudo apt-get install libgit2-dev

在那之后,工作就像一个魅力。

于 2021-01-13T13:58:17.660 回答
0

Centos 6.8

这项工作对我来说就像魅力

  1. 安装 libcurl$yum -y install libcurl libcurl-devel
  2. 重启 R 软件$rstudio-server verify-installation
于 2019-01-28T09:09:30.393 回答