【问题标题】:R/ RStudio - install devtools fails?R/RStudio - 安装开发工具失败?
【发布时间】:2017-10-28 21:51:28
【问题描述】:

我正在尝试在我的 RStudio 中安装 devtools。但是我得到了很多错误:

* installing *source* package ‘curl’ ...
** package ‘curl’ successfully unpacked and MD5 sums checked
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/lau/R/x86_64-pc-linux-gnu-library/3.4/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 PKG_CFLAGS=
Using PKG_LIBS=-lssl -lcrypto
------------------------- ANTICONF ERROR ---------------------------
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: configuration failed for package ‘openssl’
* removing ‘/home/lau/R/x86_64-pc-linux-gnu-library/3.4/openssl’
Warning in install.packages :
  installation of package ‘openssl’ had non-zero exit status
* installing *source* package ‘git2r’ ...
** package ‘git2r’ successfully unpacked and MD5 sums checked
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing inflate... -lz
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for libssl... no
configure: WARNING: "pkg-config failed to find libssl."
checking for library containing EVP_EncryptInit... no
configure: error: in `/tmp/RtmpWzaIce/R.INSTALL67fa335a4d20/git2r':
configure: error: 
  ---------------------------------------------
   The OpenSSL library that is required to
   build git2r was not found.

   Please install:
     libssl-dev    (package on e.g. Debian and Ubuntu)
     openssl-devel (package on e.g. Fedora, CentOS and RHEL)
     openssl       (Homebrew package on OS X)
   and try again.

   If the OpenSSL library is installed on
   your system but the git2r configuration
   is unable to find it, you can specify
   the include and lib path to OpenSSL with:
   R CMD INSTALL --configure-args='--with-libssl-include=INCLUDE_PATH --with-libssl-lib=LIB_PATH' git2r
  ---------------------------------------------
See `config.log' for more details
ERROR: configuration failed for package ‘git2r’
* removing ‘/home/lau/R/x86_64-pc-linux-gnu-library/3.4/git2r’
Warning in install.packages :
  installation of package ‘git2r’ had non-zero exit status
ERROR: dependencies ‘curl’, ‘openssl’ are not available for package ‘httr’
* removing ‘/home/lau/R/x86_64-pc-linux-gnu-library/3.4/httr’
Warning in install.packages :
  installation of package ‘httr’ had non-zero exit status
ERROR: dependencies ‘httr’, ‘git2r’ are not available for package ‘devtools’
* removing ‘/home/lau/R/x86_64-pc-linux-gnu-library/3.4/devtools’
Warning in install.packages :
  installation of package ‘devtools’ had non-zero exit status

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

于是我尝试安装libcurl:

> install.packages("libcurl")
Installing package into ‘/home/lau/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘libcurl’ is not available (for R version 3.4.0)
> install.packages("curl")

我使用的是 Ubuntu 17.04。和 R 3.4。

有什么办法可以解决这个问题吗?

【问题讨论】:

  • 你可以试试sudo apt-get install libssl-dev
  • @akrun 谢谢。现在可以了。

标签: r rstudio devtools


【解决方案1】:

错误消息可能有点令人困惑,因为 RStudio 要求您为 Linux 操作系统安装 libcurl 和 openssl 库;对于那些你实际上需要 Ubuntu 包而不是 R 包的人。

打开命令行终端,输入

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

一旦你的 Ubuntu 包安装完成,再试一次,你就可以安装 devtools R 包了

【讨论】:

  • 这在 Ubuntu 16.04 上对我有用。您不需要关闭并重新打开 RStudio 即可工作。
  • 不适用于 Ubuntu 18.04 - libssl-dev:取决于:libssl1.1 (= 1.1.0g-2ubuntu4.1) 但 1.1.0h-2.0+ubuntu16.04.1+deb.sury.org +1
  • 我还需要在上面包含libxml2-dev 才能安装devtools。
【解决方案2】:

我们可以使用

sudo apt-get install libssl-dev

【讨论】:

    【解决方案3】:

    您的问题包含答案:-

    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)
    

    【讨论】:

      【解决方案4】:

      错误信息: 在 pkg-config 搜索路径中找不到软件包 libcurl。也许你应该添加包含`libcurl.pc'的目录

      执行了这个命令:

      rpm -qa|grep 卷曲

      结果

      python-pycurl-7.19.0-19.el7.x86_64  
      curl-7.29.0-42.el7_4.1.x86_64  
      libcurl-7.29.0-42.el7_4.1.x86_64  
      -->libcurl-devel-7.29.0-42.el7_4.1.x86_64  <---this entry was missing
      

      执行了这个命令

      yum 安装 libcurl-devel

      问题解决了。

      【讨论】:

      • 这个答案通过一些代码格式会更容易阅读
      【解决方案5】:

      以上答案都不适用于我在 Ubuntu 18.04.3 LTS 上使用 R 版本 3.6.1

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

      对我有用的是:

      conda install -c r r-devtools 
      

      然后在R

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

      我应该提到 conda 作为 R 的包管理器效果很好,但你应该尽可能地坚持 conda,ie 不要在 R 中安装包,但使用 CONDA (除非没有该软件包的配方)使用conda-forgebiocondadefaults 频道(开源频道);注意不要与专有频道混用(例如 anacondar)。

      当您需要正在使用的通道集中不可用的软件包时,您必须手动将它们安装到 conda 环境之外的外部位置。例如,.libPaths() 表示我有两个库:

      • /home/tsundoku/anaconda3/lib/R/library #anaconda 包存放在哪里
      • /usr/lib/R/library # 我在外部存储包裹的位置

      有关管理.libPaths() 的详细信息,请参阅@MilesMcBainblog-post here

      【讨论】:

        猜你喜欢
        • 2014-10-30
        • 2019-08-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-02-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多