Problem compiling "igraph" package: libxml/globals.h: No such file or directory
thms3 opened this issue · comments
Hello,
Since yesterday, I have an issue when I want to install or update the package (dependency), on ubuntu 22.04.
vendor/cigraph/src/io/graphml.c:46:10: fatal error: libxml/globals.h: No such file or directory
46 | #include <libxml/globals.h>
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [/usr/lib/R/etc/Makeconf:191: vendor/cigraph/src/io/graphml.o] Error 1
ERROR: compilation failed for package ‘igraph’
* removing ‘/home/thomas/R/x86_64-pc-linux-gnu-library/4.3/igraph’
* restoring previous ‘/home/thomas/R/x86_64-pc-linux-gnu-library/4.3/igraph’
The downloaded source packages are in
‘/tmp/Rtmp2ATMaf/downloaded_packages’
Warning message:
In install.packages("igraph") :
installation of package ‘igraph’ had non-zero exit status
To try to solve the problem :
- I updated or installed
libxslt1-dev
,libxml2-dev
,libglpk-dev
andlibgmp-dev
debian/ubuntu packages - I installed
XML
andxml2
R packages (why not)
R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3; LAPACK version 3.10.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=sv_SE.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=sv_SE.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=sv_SE.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=sv_SE.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Stockholm
tzcode source: system (glibc)
attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] fission_1.20.0 SummarizedExperiment_1.30.2
[3] Biobase_2.60.0 GenomicRanges_1.52.1
[5] GenomeInfoDb_1.36.4 IRanges_2.34.1
[7] S4Vectors_0.38.2 BiocGenerics_0.46.0
[9] MatrixGenerics_1.12.3 matrixStats_1.2.0
loaded via a namespace (and not attached):
[1] zlibbioc_1.46.0 Matrix_1.6-5 lattice_0.22-5
[4] abind_1.4-5 GenomeInfoDbData_1.2.10 S4Arrays_1.0.6
[7] XVector_0.40.0 RCurl_1.98-1.14 bitops_1.0-7
[10] grid_4.3.2 DelayedArray_0.26.7 compiler_4.3.2
[13] tools_4.3.2 BiocManager_1.30.22 crayon_1.5.2
is R pointing to libxml2 in your anaconda library (if you have one) ? Or the systemwide libxml2 in /usr/include/libxml2/libxml? I'm trying to get it to point to the system wide installation but I'm having trouble. I've deactivated conda, and it's still pointing to the conda install of libxml2. I'm also trying to change CPPFLAGS but it doesn't seem to be working.
igraph/rigraph#1183
see issue above.
deactivate any conda environments running. open R in the terminal, and install igraph there.
@cyrusmallon I don't have deep expertise in docker or environment management. But what I know is, it is possible to run programs from a conda environment locally without conda activation (I have done a little tinker 😅 ). And vice versa I have already executed programs in a conda environment on locally installed libraries (I explored the potential of my discovery 😆 ) For my point of view, anaconda is dependency manager with pre-compiled library, allows easy local installation without being at the same level of independence as a docker. That's what I guess but I'm not sure of about anything 😅
I have this issue with R libraries installed locally on my machine. So I'm not sure that this way solves your problem.
I will find out about CPPFLAGS.
when you're trying to install, check the output and see if R is using the anaconda/conda libxml library or the system wide libxml in /usr/include. It should not be coming from the anaconda library. This will cause problems.
Hey! Just hopping on this because I had a similar issue. For me it was indeed caused by R using the anaconda libxml library path instead of the system wide libxml (I wasn't in a conda environment though).
I tried setting the paths manually two ways, but neither worked:
- By running
export LIBRARY_PATH="/usr/lib:/usr/local/lib:$LIBRARY_PATH"
and
export CPATH="/usr/include:/usr/local/include:$CPATH"
- By using "withr":
#install.packages("withr")
library(withr)
with_envvar(c(LIBRARY_PATH = "/usr/lib:/usr/local/lib",
CPATH = "/usr/include:/usr/local/include"),
install.packages("igraph"))
I ended up using a brute force solution of temporarily removing anaconda from PATH:
# Backup PATH
export PATH_BACKUP=$PATH
# Remove Anaconda from PATH
export PATH=$(echo $PATH | tr ':' '\n' | grep -v 'anaconda3\|miniconda3' | paste -s -d: -)
# Start R / install igraph
R
# Restore PATH
export PATH=$PATH_BACKUP`
This worked, but I am sure there is a better way to do it. Just dropping this here since it provided a temporary solution, but would love to hear if there is an alternative.
@thms3 can you please also include:
igraph
's configure output? It should be reporting the library link flags it's using.- The actual compiler invocation that's failing as well.
igraph
installs without any issue on my Ubuntu 22.04 VM, so there must be something unique to your machine / environment that's causing this.
The downloaded source packages are in
‘/tmp/Rtmp2ATMaf/downloaded_packages’
Warning message:
In install.packages("igraph") :
installation of package ‘igraph’ had non-zero exit status
Are you sure this is related to renv
? It looks like you're using utils::install.packages()
rather than renv::install()
, or any other related renv
machinery.
For reference, igraph
prints out for me:
libxml2 include directory: /usr/include/libxml2
And the compiler invocation:
gcc -I"/opt/R/4.2.3/lib/R/include" -DNDEBUG -DUSING_R -I. -Ivendor -Ivendor/cigraph/src -Ivendor/cigraph/include -Ivendor/cigraph/vendor -I"/usr/include/libxml2" -DNDEBUG -DNTIMER -DNPRINT -DINTERNAL_ARPACK -DIGRAPH_THREAD_LOCAL= -DPRPACK_IGRAPH_SUPPORT -DHAVE_GFORTRAN=1 -D_GNU_SOURCE=1 -I'/home/kevin/scratch/igraph-example/renv/library/R-4.2/aarch64-unknown-linux-gnu/cpp11/include' -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fvisibility=hidden -fpic -g -O2 -c vendor/cigraph/src/io/graphml.c -o vendor/cigraph/src/io/graphml.o
I think that I just found the problem ! 🎉
libxml2 include directory: /home/thomas/anaconda3/include/libxml2 -I/home/thomas/anaconda3/include
I don't know how to solve the problem yet, but I will find out 😄
Thank you very much to everybody !!