Cant install XML despite having all dependencies

Hi all
going nuts trying to install XML, in Rstudio,on Linux LEAP.
The issue seems to be it cant find key functions in libxml2, libxml, and lz. I have all these packages installed in my system, uptodate, and have provided R with environmental variables to direct to the right location, in my .Renviron file. For example, for libxml2:

LIBXML_INCDIR=/usr/include/libxml2
LIBXML_LIBDIR=/usr/lib64
PKG_CONFIG_PATH=/usr/lib64/pkgconfig
LDFLAGS=-L/usr/include/libxml2
CPPFLAGS=-I/usr/include/libxml2

All these locations are correct. When trying to install (install.packages("XML")), the command outputs:
Checking directory of LIBXML_INCDIR
Located parser file /usr/include/libxml2/parser.h
Checking for 1.8: /usr/include/libxml2
Using libxml2.*
checking for gzopen in -lz... no
checking for xmlParseFile in -lxml2... no
So it seems to be using the env variable LIBXML_INCDIR correctly, finding my package location correctly, etc. And yet it cant find the required functions.
Any idea would be much appreciated...
Am using R 4.1.2 (latest version available for LEAP) and libxml2 2.9.14 - both should be compatible with XML current version.
Thanks
Leah

I tried this on "openSUSE Leap 15.5", it should work on older versions as well. First install pak, see All about installing pak. — Installing pak • pak

stream <- "rc"
install.packages("pak", repos = sprintf(
  "https://r-lib.github.io/p/pak/%s/%s/%s/%s",
  stream,
  .Platform$pkgType,
  R.Version()$os,
  R.Version()$arch
))

Then unset all environment variables that you set, they are not needed. pak . Install the libxml2-devel package with zypper. Then install XML:

pak::pkg_install("XML")

Some related tips:

Thanks Gabor
Good to know about these resources
Specificially for the XML install problem - pak throws this compilation error that i dont know how to troubleshoot:
pak::pkg_install("XML")
:heavy_check_mark: Updating metadata database ... done

→ Will install 1 package.
→ The package (971.99 kB) is cached.

  • XML 3.99-0.16.1 [bld][cmp] + :heavy_check_mark: libxml2-devel
    :heavy_check_mark: All system requirements are already installed.

:information_source: No downloads are needed, 1 pkg (971.99 kB) is cached
:information_source: Building XML 3.99-0.16.1
:heavy_multiplication_x: Failed to build XML 3.99-0.16.1
Error:
! error in pak subprocess
Caused by error in stop_task_build(state, worker):
! Failed to build source package XML.
Type .Last.error to see the more details.

.Last.error
<callr_error/rlib_error_3_0/rlib_error/error>
Error:
! error in pak subprocess
Caused by error in stop_task_build(state, worker):
! Failed to build source package XML.


Backtrace:

  1. pak::pkg_install("XML")
  2. pak:::remote(function(...) get("pkg_install_do_plan", asNamespace("pak"))(...), …
  3. err$throw(res$error)

Subprocess backtrace:

  1. base::withCallingHandlers(cli_message = function(msg) { …
  2. get("pkg_install_do_plan", asNamespace("pak"))(...)
  3. proposal$install()
  4. pkgdepends::install_package_plan(plan, lib = private$library, num_workers = nw, …
  5. base::withCallingHandlers({ …
  6. pkgdepends:::handle_events(state, events)
  7. pkgdepends:::handle_event(state, i)
  8. pkgdepends:::stop_task(state, worker)
  9. pkgdepends:::stop_task_build(state, worker)
  10. base::throw(pkg_error("Failed to build source package {.pkg {pkg}}.", …
  11. | base::signalCondition(cond)
  12. global (function (e) …

This using gcc-12 and gcc-c++12 (version set with "CC" and "CXX" flags; have alos tried with verison 11 or my default 7.5; all produce same error)
Sorry for teh late reply , dindt see you had posted here
thanks!
Leah

What is in your ~/.R/Makevars file? Can you try ti without an ~/.R/Makevars file?

Can you try to install the same package with install.packages(), so we see why it fails?

Hi Tnx!
In .R/Makevars I ahve only this -
CXX_STD = CXX17
PKG_CPPFLAGS = -std=c++17
Tried commenting them out and restarting - get same error message
Most of my variabels i set in .Renviron, or also in session to be sure -this is my .Renviron:
GNU nano 6.3 /home/leah/.Renviron
GOPHNA_ROOT=/home/leah/Documents/GitHub
LIBXML_INCDIR=/usr/include/libxml2
LIBXML_LIBDIR=/usr/lib64
PKG_CPPFLAGS="-I/usr/include/libxml2"
PKG_LIBS="-lxml2"
PKG_CONFIG_PATH=/usr/lib64/pkgconfig
#PKG_LIBS=-L/lib64 -lz
#PKG_LIBDIR=/lib64
#LDFLAGS=-L/usr/include/libxml2
#CPPFLAGS=-I/usr/include/libxml2
(The ones which are commented out now, I had tried adding before, no use).
install.packages, remotes::install_github, and installing from source - all produce the same error message which drives me nuts:

  • installing source package ‘XML’ ...
    ** package ‘XML’ successfully unpacked and MD5 sums checked
    ** using staged installation
    configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu
    checking for gcc... /usr/bin/gcc-11
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether the compiler supports GNU C... yes
    checking whether /usr/bin/gcc-11 accepts -g... yes
    checking for /usr/bin/gcc-11 option to enable C11 features... none needed
    checking how to run the C preprocessor... /usr/bin/gcc-11 -E
    checking for sed... /usr/bin/sed
    checking for pkg-config... /usr/bin/pkg-config
    Checking directory of LIBXML_INCDIR
    Located parser file /usr/include/libxml2/parser.h
    Checking for 1.8: -I/usr/include/libxml2 /usr/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’

Cause if I understand it correctly - it first finds my libxml2-devel, but THEN says it cant find xmlParseFile. my libxml2 is right where I pointed it, it HAS xmlParseFile - I checked, and besides, I managed to install otehr packages whcih depend on it. But I cant install this one.

You do not need to set any env vars, try removing all XML related env vars. You also don't need PKG_CPPFLAGS, etc.

This Dockerfile works fine for me:

FROM opensuse/leap:15.5
RUN zypper -n install R
RUN zypper -n install libxml2-devel make gcc
RUN R -q -e 'source("https://pak.r-lib.org/install.R")'
RUN R -q -e 'pak::pkg_install("XML")'

I didnt originally have these env vars - up till now R packages had installed easily.
I only started setting these flags when XML install failed; I had thought teh problem may be its not finding/linking properly to libxml2-devel or to libz. BTW I also have these libraries in miniconda3 libraries and didnt want R going tehre instaed of to the system-wide install.
Anyway - removed all vars and ran again - same error exactly. not repasting here cause its similar to above.

You need to deactivate conda if you are installing packages in non-conda R.

this is a bit of a different story....what you are suggesting is to install docker, create a new docker image in which i will be emulating LEAP, and install everything new in there. I may try that if all else fails but I cant understand why the install shouldnt work on the system I already have set up. R is the main thing I work with, I already have loads of other packages installed, and prefer not to work within an emulation of the OS I already have anyway.

conda is deactivated. Still the libraries exist and wanted to be on teh safe side.

No, I am not suggesting to install Docker. I showed the Dockerfile to show that the installation works out of the box on a vanilla OpenSUSE Leap system. It clearly does not work for you because of the additional config, partially set by you, partially set by conda.

What I was suggesting is removing the env vars, and deactivating conda.

done both. same error.
I understand its something interferring on my system, since XML is so widely used.
But for the life of me I cant debug it :frowning: !

The error message makes no sense to me.
This part states it found libxml2:

Checking directory of LIBXML_INCDIR
Located parser file /usr/include/libxml2/parser.h
Checking for 1.8: -I/usr/include/libxml2 /usr/include/libxml2
Using libxml2.*

But then the next lines says it cant find it:

checking for gzopen in -lz... no
checking for xmlParseFile in -lxml2... no
checking for xmlParseFile in -lxml... no
configure: error: "libxml not found"

Also its looks like its not finding libz (which is installed, same location as libml2).

I guess this still means that LIBXML_INCDIR is set for you. Make sure that it is not set. Also run zypper install libxml2-devel to make sure the libraries are installed. If you have other installation of libxml2-dev in /usr/local/, remove that. (The conda should be fine, as long as conda is deactivated.)

Here is the configure output of a successful installation:

* installing *source* package 'XML' ...
** package 'XML' successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking how to run the C preprocessor... gcc -E
checking for sed... /usr/bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking for xml2-config... /usr/bin/xml2-config
USE_XML2 = yes
SED_EXTENDED_ARG: -E
Minor 10, Patch 3 for 2.10.3
Located parser file -I/usr/include/libxml2/parser.h
Checking for 1.8:  -I/usr/include/libxml2
Using libxml2.*
checking for gzopen in -lz... yes
checking for xmlParseFile in -lxml2... yes
checking for xmlHashSize in -lxml2... yes
Using built-in xmlHashSize
Checking DTD parsing (presence of externalSubset)...
checking for xmlHashSize in -lxml2... (cached) yes
Found xmlHashSize
checking for xmlOutputBufferCreateBuffer in -lxml2... yes
have xmlOutputBufferCreateBuffer()
checking for xmlDocDumpFormatMemoryEnc in -lxml2... yes
checking for libxml/xmlversion.h... yes
Expat:  FALSE
Checking for return type of xmlHashScan element routine.
No return value for xmlHashScan
xmlNs has a context field
Checking for cetype_t enumeration
Using recent version of R with cetype_t enumeration type for encoding
checking for xmlsec1-config... no
nodegc default
xml-debug default
Version has XML_WITH_ZLIB
Version has xmlHasFeature()

****************************************
Configuration information:

Libxml settings

libxml include directory: -I/usr/include/libxml2
libxml library directory: -lxml2 -lz -llzma -lm -ldl -lz  -lxml2
libxml 2:                 -DLIBXML2=1

Compilation flags:         -DLIBXML -I/usr/include/libxml2 -DUSE_EXTERNAL_SUBSET=1 -DROOT_HAS_DTD_NODE=1 -DDUMP_WITH_ENCODING=1 -DUSE_XML_VERSION_H=1 -DXML_ELEMENT_ETYPE=1 -DXML_ATTRIBUTE_ATYPE=1 -DNO_XML_HASH_SCANNER_RETURN=1 -DLIBXML_NAMESPACE_HAS_CONTEXT=1 -DHAVE_R_CETYPE_T=1 -DHAVE_XML_WITH_ZLIB=1 -DHAVE_XML_HAS_FEATURE=1 -DUSE_R=1 -D_R_=1  -DHAVE_VALIDITY=1 -DXML_REF_COUNT_NODES=1
Link flags:               -lxml2 -lz -llzma -lm -ldl -lz  -lxml2

hey, you're right it remembered the path I had set in LIBXML_INCDIR until I logged out ...
now, if I run without any flags at all, and though conda IS deactivated, I swear - R takes the libxml2 and xml2 from conda lib instead of the system-wide installs (which are in /usr/lib64/). And then it does find libxml2 and libz , but reports incompatibilities - that was teh reason I had set teh LIBXML_INCDIR and LIBXML_LIBDIR explicitly to point to teh system-wide install

checking for pkg-config... /usr/bin/pkg-config
checking for xml2-config... /home/leah/miniconda3/bin/xml2-config
USE_XML2 = yes
SED_EXTENDED_ARG: -E
Minor 10, Patch 4 for 2.10.4
Located parser file -I/home/leah/miniconda3/include/libxml2 -I/home/leah/miniconda3/include/parser.h
Checking for 1.8: -I/home/leah/miniconda3/include/libxml2 -I/home/leah/miniconda3/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.

This means that /home/leah/miniconda3/bin is still on your PATH. That should not happen if conda is deactivated. Maybe you modified your PATH manually. In any case, make sure that conda is not on your PATH.

echo $PATH
/usr/lib64:/usr/share:/home/leah/bin:/usr/local/bin:/usr/bin:/bin:/home/leah/bin/FastQC:/home/leah/edirect

I had removed it totally from the PATH, at least from the part thats accessible to me ( I think there's also a system PATH variable thats not so accessible, am still trying to dig that up, maybe thats where the miniconda path is hiding).
But isn't that exactly what the R system envs - LIBXML_LIBDIR and so on are intended for? so we can configure R to use what we want without modifying teh entire system...?
BTW, much appreciate your assitance, if all this is taking up too much time, I'll understand if you dont respond

Dear man- you solved it!
Thank you so much , i was nowhere near close to solving it.
Note to myself - after modifying PATH, need to logout for it to take effect - merely sourcing .bashrc was not enough :smiling_face:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.