Problems install R XML package on CentOS 7
1
1
Entering edit mode
kai.karius ▴ 10
@kaikarius-13915
Last seen 7.2 years ago

Dear all,

I am trying to install the XML package via BiocLite, which I need for various other packages. Yet there seems to be a problem with libxml2. I run CentOS and have installed the libxml-devel package via yum which is encouraged online. R itself was installed using anaconda. The output is this:

> source("https://bioconductor.org/biocLite.R")
Bioconductor version 3.5 (BiocInstaller 1.26.1), ?biocLite for help
> biocLite("XML")
BioC_mirror: https://bioconductor.org
Using Bioconductor 3.5 (BiocInstaller 1.26.1), R 3.4.1 (2017-06-30).
Installing package(s) ‘XML’
trying URL 'https://cran.rstudio.com/src/contrib/XML_3.98-1.9.tar.gz'
Content type 'application/x-gzip' length 1599437 bytes (1.5 MB)
==================================================
downloaded 1.5 MB

* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
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 how to run the C preprocessor... gcc -E
checking for sed... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking for xml2-config... /home/kkarius/anaconda3/bin/xml2-config
USE_XML2 = yes
SED_EXTENDED_ARG: -E
Minor 9, Patch 4 for 2.9.4
Located parser file -I/home/kkarius/anaconda3/include/libxml2 -I/home/kkarius/anaconda3/include/parser.h
Checking for 1.8:  -I/home/kkarius/anaconda3/include/libxml2 -I/home/kkarius/anaconda3/include
Using libxml2.*
checking for gzopen in -lz... yes
checking for xmlParseFile in -lxml2... yes
You are trying to use a version 2.* edition of libxml
but an incompatible library. The header files and library seem to be
mismatched. If you have specified LIBXML_INCDIR, make certain to also
specify an appropriate LIBXML_LIBDIR if the libxml2 library is not in the default
directories.
ERROR: configuration failed for package ‘XML’
* removing ‘/home/kkarius/anaconda3/lib/R/library/XML’

The downloaded source packages are in
    ‘/tmp/RtmpY66UhU/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages(pkgs = doing, lib = lib, ...) :
  installation of package ‘XML’ had non-zero exit status


While the sessionInfo() output is:

> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS: /home/kkarius/anaconda3/lib/R/lib/libRblas.so
LAPACK: /home/kkarius/anaconda3/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] BiocInstaller_1.26.1

loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1   


Any help?

Thanks in advance.

All the best

 

r packages centos7 bioclite libxml2 • 8.3k views
ADD COMMENT
2
Entering edit mode
@pariksheet-nanda-10892
Last seen 2.5 years ago
University of Connecticut

Generally to troubleshoot a configure problem, you should download the package tarball, run the installation, and inspect the config.log file.

The problem in this case is the configure script incorrectly judges you to be using libxml 1 from parsing the include directory. If it detects the directory name as libxml instead of libxml2 it assumes you're using libxml1.

You can confirm this on your system by checking rpm -ql libxml2-devel | grep include | head -4 if also see the include files installed in /usr/include/libxml2/libxml

I wasn't see anyway to override this false positive libxml1 check, so a hack of a workaround you can use is to patch out that branch of the configure script. Because configure it self is autogenerated from configure.ac using autotools, one patches configure.ac and can then run autoreconf.

url=https://cloud.r-project.org/src/contrib/XML_3.98-1.9.tar.gz
tarball=$(basename $url)
tardir=${tarball%_*}
test ! -e $tarball && wget $url -O $tarball
test ! -d $tardir && tar -xf $tarball

# Remove false positive libxml-1 detection from configure script.
patch=remove_libxml1_check.patch
cat <<EOF> $patch
--- XML/configure.in.orig    2012-10-14 17:12:28.000000000 -0400
+++ XML/configure.in    2017-09-05 18:04:34.144620739 -0400
@@ -412,28 +412,6 @@
     LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:\${LIBXML_LIBDIR}
     export LD_LIBRARY_PATH
    fi
-   AC_TRY_RUN([
-#ifdef FROM_GNOME_XML_DIR
-#include <gnome-xml parser.h="">
-#else
-#include <libxml parser.h="">
-#endif
-int 
-main(int argc, char *argv[])
-{
-  xmlCheckVersion(20000);
-  return(0);
-}
-    ],[ LIBXML2_OK=1],[LIBXML2_OK=0])
-
-    if test "\${LIBXML2_OK}" = "0" ; then 
-     echo "You are trying to use a version 2.* edition of libxml"
-     echo "but an incompatible library. The header files and library seem to be"
-     echo "mismatched. If you have specified LIBXML_INCDIR, make certain to also"
-     echo "specify an appropriate LIBXML_LIBDIR if the libxml2 library is not in the default"
-     echo "directories."
-     exit 1
-    fi
   fi

   if test -n "\${USE_OLD_ROOT_CHILD_NAMES}" ; then
EOF

# Using the `patch -b` argument creates an *.orig backup file
# which we can use to avoid the "already patched" error from
# re-running `patch`.
if ! [[ -e XML/configure.in.orig ]]; then
    patch -b XML/configure.in <$patch
    autoreconf XML/
fi

# Install XML
R -q --vanilla <<EOF options(repos="structure(c(CRAN" =="" "<a="" href="&lt;a href=" https:="" cloud.r-project.org="" "="" rel="nofollow">https://cloud.r-project.org/" rel="nofollow">https://cloud.r-project.org/")))
devtools::install("./XML",
                  force = TRUE,
                  args = "--configure-args='--with-libxml2'")
EOF

If this is the same problem for you as it was for me, we should report the problem upstream to the XML maintainers.

ADD COMMENT
0
Entering edit mode

Looks like the new markdown functionality is affecting the last section`# Install XML` with an `a href` tags, but looks normal when I try to edit the post.

Rewritten here without markdown:

# Install XML
R -q --vanilla <
devtools::install("./XML",
force = TRUE,
args = "--configure-args='--with-libxml2'")
EOF

ADD REPLY
0
Entering edit mode

So ... i followed your advice (kind of):

setenv LIBXML_LIBDIR /home/***/anaconda3/lib/

setenv LIBXML_INCDIR /home/***/anaconda3/include/libxml2/

R CMD INSTALL XML

produces

* installing to library ‘/home/***/anaconda3/lib/R/library’
* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
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 how to run the C preprocessor... gcc -E
checking for sed... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
Checking directory of LIBXML_INCDIR
Located parser file /home/***/anaconda3/include/libxml2//parser.h
Checking for 1.8:  /home/***/anaconda3/include/libxml2/
Using libxml2.*
checking for gzopen in -lz... no
checking for xmlParseFile in -lxml2... no
checking for xmlParseFile in -lxml... no
configure: error: "libxml not found"
ERROR: configuration failed for package ‘XML’

 

 

 

Any ideas?

ADD REPLY
1
Entering edit mode

Ah, so you're using Anaconda's R distribution.  Why don'y you use the conda package for CRAN's XML (called r-xml)?  To reproduce your problem I installed Anaconda3 4.4.0 on RedHat 7.4, then:

cat 'export PATH=$PATH:~/anaconda3/bin' >> ~/.bashrc
source ~/.bashrc
conda install -c r r-essentials  # suggested by https://docs.continuum.io/anaconda/packages/r-language-pkg-docs.html
Rscript -e 'library(XML)'  # error
conda install r-xml
Rscript -e 'library(XML)'  # works

 

Pariksheet

ADD REPLY

Login before adding your answer.

Traffic: 821 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6