Site icon R-bloggers

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

[This article was first published on Econometrics and Free Software, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 source:

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

This library, libicui18n.so.58 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 libicui18n.so.58

/home/cbrunos/miniconda3/lib/libicui18n.so.58
/home/cbrunos/miniconda3/lib/libicui18n.so.58.2
/home/cbrunos/miniconda3/pkgs/icu-58.2-h9c2bf20_1/lib/libicui18n.so.58
/home/cbrunos/miniconda3/pkgs/icu-58.2-h9c2bf20_1/lib/libicui18n.so.58.2

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/):

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/username/miniconda3/lib/
export LD_LIBRARY_PATH

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 = "http://cran.rstudio.com/"))

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/DT@master 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: 
<Anonymous> ... 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 paypal.me.

  • Buy me an Espresso

    To leave a comment for the author, please follow the link and comment on their blog: Econometrics and Free Software.

    R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
    Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.