【问题标题】:install.packages("devtools") on R 3.0.2 fails in Ubuntu 14.04R 3.0.2 上的 install.packages("devtools") 在 Ubuntu 14.04 中失败
【发布时间】:2015-06-12 01:34:58
【问题描述】:

我正在尝试在 Ubuntu 14.04 上安装 R 3.0.2 devtools 包,如下所示:

install.packages("devtools")

我得到以下结果:

Installing package into ‘/home/jim/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Warning: dependency ‘xml2’ is not available
also installing the dependency ‘rversions’

trying URL 'http://cran.rstudio.com/src/contrib/rversions_1.0.1.tar.gz'
Content type 'application/x-gzip' length 4624 bytes
opened URL
==================================================
downloaded 4624 bytes

trying URL 'http://cran.rstudio.com/src/contrib/devtools_1.8.0.tar.gz'
Content type 'application/x-gzip' length 141487 bytes (138 Kb)
opened URL
==================================================
downloaded 138 Kb

ERROR: dependency ‘xml2’ is not available for package ‘rversions’
* removing ‘/home/jim/R/x86_64-pc-linux-gnu-library/3.0/rversions’
ERROR: dependency ‘rversions’ is not available for package ‘devtools’
* removing ‘/home/jim/R/x86_64-pc-linux-gnu-library/3.0/devtools’

The downloaded source packages are in
    ‘/tmp/RtmpmDzsRJ/downloaded_packages’
Warning messages:
1: In install.packages("devtools") :
  installation of package ‘rversions’ had non-zero exit status
2: In install.packages("devtools") :
  installation of package ‘devtools’ had non-zero exit status

似乎存在对名为 xml2 的包的依赖项。有谁知道我在哪里可以找到这个包以及如何安装它。

我已经安装了以下:

sudo apt-get install libxml2-dev
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install curl

【问题讨论】:

  • this Ubuntu repo on every CRAN mirror安装R 3.2.0;一切都会到位。
  • sudo apt-get update ... 然后 sudo apt-get install r-base ... 将安装以下新软件包:r-base 0 升级,1 新安装,0 删除和 3 没有升级。需要获取 0 B/9,568 B 的档案。此操作后,将使用 73.7 kB 的额外磁盘空间。选择以前未选择的包 r-base。 (正在读取数据库...当前安装的 201581 个文件和目录。) 准备解压 .../r-base_3.0.2-1ubuntu1_all.deb ... 解压 r-base (3.0.2-1ubuntu1) ... 设置 r -base (3.0.2-1ubuntu1) ... jim@Ubuntu14:~$ 3.0.2 仍在安装中
  • 您是否按照@DirkEddelbuettel 发布的链接中的建议向 /etc/apt/sources.list 添加了条目?

标签: linux r ubuntu


【解决方案1】:

如果使用软件中心在 Ubuntu 中安装 R,则包含构建 Ubuntu 时的稳定版本。因此安装了 R 3.0.2。

将以下内容添加到 /etc/apt/sources.list:

deb http://cran.rstudio.com/bin/linux/ubuntu trusty/

导致当前版本(R 3.2.0)被加载。

我必须安装以下 OpenSSL 库

sudo apt-get install libssl-dev

然后我能够启动 R 并成功安装 'devtools'

非常感谢 Dirk 和 Pascal 的建议。

【讨论】:

【解决方案2】:

另一个解决方案(在版本 R 3.2.2 上)是安装 lxml:

$ apt-get install libxml2-dev libxslt-dev

成功消除了R错误:

错误:“xml2”包配置失败

运行时出现在R中

install.packages("devtools")

【讨论】:

  • libxml2-dev 依赖项还修复了roxygen2 在基于 Debian 的 Linux 上的潜在安装问题。