Failed to install devtools in R 3.1.2

6.7k views Asked by At

I was trying to install the devtools package in Rstudio by install.packages("devtools") but failed. The error messages are:

* installing *source* package ‘xml2’ ...
** package ‘xml2’ successfully unpacked and MD5 sums checked
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
Could not find libxml2. Please install libxml2-devel (rpm) or libxml2-dev (deb).
ERROR: configuration failed for package ‘xml2’
* removing ‘/home/xwang/R/x86_64-pc-linux-gnu-library/3.1/xml2’
Warning in install.packages :
  installation of package ‘xml2’ had non-zero exit status
ERROR: dependency ‘xml2’ is not available for package ‘rversions’
* removing ‘/home/xwang/R/x86_64-pc-linux-gnu-library/3.1/rversions’
Warning in install.packages :
  installation of package ‘rversions’ had non-zero exit status
ERROR: dependency ‘rversions’ is not available for package ‘devtools’
* removing ‘/home/xwang/R/x86_64-pc-linux-gnu-library/3.1/devtools’
Warning in install.packages :
  installation of package ‘devtools’ had non-zero exit status

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

Looks like it has trouble finding libxml-2.0. Does anyone know an easy fix to this? I'm using R version 3.1.2.

3

There are 3 answers

2
xiaoxiao87 On

Eventually I fixed the problem by:

sudo apt-get install libxml2-dev

Then another problems popped up:

Error : object ‘curl_fetch_memory’ is not exported by 'namespace:curl'

which can be solved by installing the curl package:

install.packages("curl")
0
AudioBubble On

You just need to update to the newest version of R (R version 3.2.1)

0
Raffaello On

It require some developer libraries (sources): curl developer, xml2 developer as dependecy. so install it with the package repository (yum, dnf, apt-get) and retry to install the devtools package in R.