For posterity: install {xml2} on GNU/Linux distros

(This article was first published on Econometrics and Free Software, and kindly contributed to R-bloggers)

Today I’ve removed my system’s R package and installed MRO instead. While re-installing all packages,
I’ve encountered one of the most frustrating error message for someone installing packages from

Error : /tmp/Rtmpw60aCp/R.INSTALL7819efef27e/xml2/man/read_xml.Rd:47: unable to load shared object
'/usr/lib64/R/library/xml2/libs/': cannot open shared object file: No such file or directory ERROR: 
installing Rd objects failed for package ‘xml2’ 

This library, is a pain in the butt. However, you can easily install it if you
install miniconda. After installing miniconda, you can look for it with:

[19-05-18 18:26] cbrunos in ~/ ➤ locate


So now you need to tell R where to look for this library. The
following Stackoverflow answer saved the day. Add the following
lines to R_HOME/etc/ldpaths (in my case, it was in /opt/microsoft/ropen/3.5.2/lib64/R/etc/):


and try to install xml2 again, and it should work! If not, just abandon the idea of using R and
switch to doing data science with VBA, it’ll be less frustrating.

Something else, if you install Microsoft R Open, you’ll be stuck with some older packages, because
by default MRO uses a snapshot of CRAN from a given day as a mirror. To get the freshest packages,
add the following line to your .Rprofile file (which should be located in your HOME):

options(repos = c(CRAN = ""))

And to finish this short blog post, add the following line to your .Rprofile
if you get the following error messages when trying to install a package from github:

remotes::install_github('rstudio/DT') Downloading GitHub repo rstudio/[email protected] tar: 
This does not look like a tar archive gzip: stdin: unexpected end of file tar: Child returned 
status 1 tar: Error is not recoverable: exiting now tar: This does not look like a tar archive 
gzip: stdin: unexpected end of file tar: Child returned status 1 tar: Error is not recoverable: 
exiting now Error in getrootdir(untar(src, list = TRUE)) : length(file_list) > 0 is not TRUE Calls: 
 ... source_pkg -> decompress -> getrootdir -> stopifnot In addition: Warning messages: 1: 
In utils::untar(tarfile, ...) : ‘tar -xf '/tmp/RtmpitCFRe/file2677442609b8.tar.gz' -C 
'/tmp/RtmpitCFRe/remotes267752f2629f'’ returned error code 2 2: 
In system(cmd, intern = TRUE) : running command 'tar -tf '/tmp/RtmpitCFRe/file2677442609b8.tar.gz'' 
had status 2 Execution halted

The solution, which can found here

options("download.file.method" = "libcurl")

Hope you enjoyed! If you found this blog post useful, you might want to follow
me on twitter for blog post updates and
buy me an espresso or

Buy me an EspressoBuy me an Espresso

To leave a comment for the author, please follow the link and comment on their blog: Econometrics and Free Software. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)