Hi there,
I am trying to install the package XML for R 4.0.5.
When I try installing it internally from R with the function install.packages(), I get the following error:
> install.packages("XML")
Retrieving 'https://cloud.r-project.org/src/contrib/XML_3.99-0.8.tar.gz' ...
OK [file is up to date]
Installing XML [3.99-0.8] ...
FAILED
Error installing package 'XML':
===============================
* installing to library ‘/home/giuliocentorame/Repositories/xxxxxx/renv/staging/1’
* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
** using staged installation
Cleaning up after installing the XML package
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... /home/giuliocentorame/anaconda3/bin/xml2-config
USE_XML2 = yes
SED_EXTENDED_ARG: -E
Minor 9, Patch 10 for 2.9.10
Located parser file -I/home/giuliocentorame/anaconda3/include/libxml2 -I/home/giuliocentorame/anaconda3/include/parser.h
Checking for 1.8: -I/home/giuliocentorame/anaconda3/include/libxml2 -I/home/giuliocentorame/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/giuliocentorame/Repositories/xxxxxx/renv/staging/1/XML’
Error: install of package 'XML' failed [error code 1]
Traceback (most recent calls last):
12: install.packages("XML")
11: install(pkgs)
10: renv_install_impl(records)
9: renv_install_staged(records)
8: renv_install_default(records)
7: handler(package, renv_install_package(record))
6: renv_install_package(record)
5: withCallingHandlers(renv_install_package_impl(record), error = function(e) {
vwritef("\tFAILED")
writef(e$output)
})
4: renv_install_package_impl(record)
3: r_cmd_install(package, path)
2: r_exec_error(package, output, "install", status)
1: stop(error
I get the same error if I use R with Anaconda. Anaconda does have an XML version built-in, but it’s for R 3.6.x (and I can’t downgrade it due to the entirety of my projects being on R 4.x.x).
Unfortunately, I have no idea on how to set up those variables and what with. I suspect it’s a libxml version conflict just like the one here, but I have no idea on how to fix it.
I tried installing it from dnf (even though it isn’t really good practice), but R doesn’t recognise it anyway.
Would you be able to help me find a fix for it? Thanks a lot
My R is installed through Fedora, I can actually ditch conda altogether for now and try to fix the integration with conda later. The only thing that I really need is the integration with renv for the time being
I can install it, but it does not change anything out of the box when I am going to install the package through R
Edit: sorry, this makes no sense. I meant that R does not recognise it as installed (I’d assume because it’s looking at renv’s folder instead of the user folder)
Reproducibility. The most important shortcoming of using R is the compatibility between modules in the R ecosystem: there are something like 18k packages at the moment in CRAN (the official repo), upgraded fairly frequently and with loads of dependencies, so even small changes in functions have consequences in the entire ecosystem and break a lot of code or make it nonreproducible. There are no Linux binaries available too, so everything is compiled from source on those systems.
This probably does not affect XML (which is a fairly stable package), but for some packages with a faster development cycle, it’s an actual issue.
The main ways to overcome this shortcoming in R are either to use a fixed release system for all of your packages, tied to the R version (e.g., in Bioconductor or the Anaconda repo), or to use renv (used to be packrat), which installs your packages in the project library and pins them to a specific version–so if you have to run the code again or transfer it to another machine it will run it installing the specific package version you’ve provided (and no conflicts with the most recent one you might have on your user library). Also, to publish on CRAN the package has to undergo some pretty mental checks (and they get unpublished very quickly), so you are usually confident that the most recent versions on CRAN won’t cause too many package dependency issues.
Distro packages tend to get outdated pretty quickly, so it can get messy with multiple sources and when adding new packages you are often forced to use everything at the most recent CRAN version, to avoid incompatibility issues (with the important exception of the R version itself, which is usually made so that things don’t break too badly between subversions).
As an example, I am currently using an average of 6-7 packages (aka “”“libraries”“”) beyond base R per script on my current project, 2 from a Github repo (tied to the commits), 4 from the official repos (tied to the CRAN release version), and 1-2 built-ins (tied to the R version). It would be really inconvenient to solve possible incompatibility issues with distro-specific package versions.
The problem I am currently having is that I would rather not use the Anaconda version of R for the current project, since it’s stuck at 3.6 and I need some changes that are present on 4.x.x. Do you think that removing it temporarily altogether would fix the issue? I would probably then proceed to containerize it all as soon as this is done
Hi @fbackstab,
Have you managed to solve the problem? I’m running precisely into the same issue, integration with renv for the package XML.
Edit: I noticed that line in @fbackstab’s first post:
It seems that could explains why the error is also present using his Anaconda’s R, both of them use xml2-config from anaconda.
I have the same issue as well: checking for xml2-config... /home/etheimer/miniconda3/bin/xml2-config
So the question becomes : why is the XML package installation not using the xml2-config in /usr/bin?
When I execute which xml2-config, I get /usr/bin/xml2-config. So the path seems correct, yet XML does not respect it? Any idea as to why?
Edit 2: I have modified the configure file after having downloaded the tar archive. Adding withval=$with_xml_config; XML_CONFIG=/usr/bin/xml2-config line 2387 and PKG_CONFIG=/usr/bin/pkg-config line 3679 solves the problem (if in a bit of a hacky way). However, this fix does not function with renv, as renv requires the packages to be dowloaded from known sources.
Hi there,
In any case someone is still struggling with this issue.
I solved the issue by having the following settings in R (installed in ubuntu cmd NOT via CONDA)
As you can see I have set the INCDIR not to point to the libxml2/libxml folder rather libxml2 folder. I guess that is one of the issues. Ensure that your libxml2.pc is also properly configured as follows (Change the prefix path)