Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Goal: Installing some R packages requires understanding what libraries are available on the System.



Start a new Session and Start R

[salexan5@mblog2 ~]$ module load gcc/13.2.0 r/4.4.0
[salexan5@mblog2 ~]$ R
R version 4.4.0 (2024-04-24) -- "Puppy Cup"
...

Try Installing R XML Package

> install.packages("XML")
...
checking for xml2-config... /apps/u/spack/gcc/13.2.0/libxml2/2.10.3-5toq4pi/bin/xml2-config
...
Located parser file -I/apps/u/spack/gcc/13.2.0/libxml2/2.10.3-5toq4pi/include/libxml2 -I/apps/u/spack/gcc/13.2.0/libiconv/1.17-3dj22ny/include/parser.h
Checking for 1.8:  -I/apps/u/spack/gcc/13.2.0/libxml2/2.10.3-5toq4pi/include/libxml2 -I/apps/u/spack/gcc/13.2.0/libiconv/1.17-3dj22ny/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 ‘/cluster/medbow/home/salexan5/R/x86_64-pc-linux-gnu-library/4.4/XML’
...

What does the error message mean?


How to Resolve XML Package Issue

We can see from the CRAM package XML description that from the System Requirements we require: libxml2 (>= 2.6.3)

We can see that the libxml2 library is available and is being picked up.

[salexan5@mblog2 ~]$ ml
Currently Loaded Modules:
...
 15) libxml2/2.10.3              56) nghttp2/1.57.0
...

Install location: /apps/u/spack/gcc/13.2.0/libxml2/2.10.3-5toq4pi

Sometimes the cause of the error isn’t obvious.

Try Googling to look for suggestions: Can not install XML package

# Withi R:
> Sys.setenv(XML_CONFIG="/apps/u/spack/gcc/13.2.0/libxml2/2.10.3-5toq4pi/bin/xml2-config")
> install.packages('XML', configure.args=c('--with-libxml2=/apps/u/spack/gcc/13.2.0/libxml2/2.10.3-5toq4pi/bin/xml2-config LIBXML_LIBDIR=-L/apps/u/spack/gcc/13.2.0/libxml2/2.10.3-5toq4pi/lib/ LIBXML_INCDIR=/apps/u/spack/gcc/13.2.0/libxml2/2.10.3-5toq4pi/include/libxml2/'))
Installing package into ‘/cluster/medbow/home/salexan5/R/x86_64-pc-linux-gnu-library/4.4’
...
* DONE (XML)

Install the R sf Package

Reading the CRAN sf definition page, take note of the system requirements:

System Requirements: GDAL (>= 2.0.1), GEOS (>= 3.4.0), PROJ (>= 4.8.0), sqlite3

What do we already have loaded?

[salexan5@mblog2 ~]$ ml
Currently Loaded Modules:
...
 35) sqlite/3.43.2               76) scrnsaverproto/1.2.2
...

We also need to manually load:

[salexan5@mblog2 ~]$ module load gdal/3.7.3 geos/3.12.0 proj/9.2.1

Install the R sf Package: Fails

> install.packages("sf")
...
also installing the dependencies ‘proxy’, ‘MASS’, ‘e1071’, ‘class’, ‘KernSmooth’, ‘wk’, ‘classInt’, ‘DBI’, ‘Rcpp’, ‘s2’, ‘units’
...
--------------------------------------------------------------------------------
  Configuration failed because libudunits2.so was not found. Try installing:
    * deb: libudunits2-dev (Debian, Ubuntu, ...)
    * rpm: udunits2-devel (Fedora, EPEL, ...)
    * brew: udunits (OSX)
  If udunits2 is already installed in a non-standard location, use:
    --configure-args='--with-udunits2-lib=/usr/local/lib'
  if the library was not found, and/or:
    --configure-args='--with-udunits2-include=/usr/include/udunits2'
  if the header was not found, replacing paths with appropriate values.
  You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
--------------------------------------------------------------------------------
ERROR: configuration failed for package ‘units’
...

Do we have a udunits module?

[powersw@mblog2 ~]$ module spider udunits
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  udunits: udunits/2.2.28
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    You will need to load all module(s) on any one of the lines below before the "udunits/2.2.28" module is available to load.
      arcc/1.0  gcc/13.2.0
    Help:
      Automated units conversion
[powersw@mblog2 ~]$ module load udunits/2.2.28

# Within R
> install.packages("sf")
...
* DONE (sf)

> library(sf)
Linking to GEOS 3.12.0, GDAL 3.7.3, PROJ 9.2.1; sf_use_s2() is TRUE

Recommendation: When ever you want to use this R package, additionally load:

[salexan5@mblog2 ~]$ gcc/13.2.0 r/4.4.0
[salexan5@mblog2 ~]$ module load gdal/3.7.3 geos/3.12.0 proj/9.2.1 udunits/2.2.28

previous section

 

next section

 

  • No labels