R fails to load igraph in conda environment

Viewed 397

I am trying to run an RShiny app in a WSL2 installation of Ubuntu on Windows. I am no expert in R, but I feel this is a problem due to conda interaction with R. I run the following commands:

conda create -n r_env r-essentials r-base
conda activate r_env
conda install -c conda-forge r-shiny
conda install -c r r-visnetwork
conda install -c conda-forge r-dplyr
conda install -c r r-dt
conda install -c conda-forge r-igraph
conda install -c r r-leaflet
conda install -c conda-forge r-rgdal
conda install -c r r-shinydashboard
conda install -c conda-forge r-shinywidgets
conda install -c conda-forge r-shinycssloaders
conda install -c conda-forge r-igraph

When I run R and type in : library(igraph) i get:

->Error: package or namespace load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/carlo/anaconda3/envs/r_env/lib/R/library/igraph/libs/igraph.so':

but I can list it, it's there:

ll /home/carlo/anaconda3/envs/r_env/lib/R/library/igraph/libs/igraph.so
-> -rwxrwxr-x 1 carlo carlo 3816608 Mar 31 15:38 /home/carlo/anaconda3/envs/r_env/lib/R/library/igraph/libs/igraph.so

Did anybody encounter a similar problem?

The igraph library was meant to load correctly

3 Answers

(My Opinion) I would caution against the use of the r channel and the r-essentials package. The Continuum/Anaconda support for R was a good college-try, but is since outmoded and superseded by the broader CRAN support that Conda Forge provides. Users managing R environments will find a better experience ignoring any Continuum/Anaconda documentation and exclusively using Conda Forge for their R environments. (End Opinion)


Mixing channels can lead to symbol reference errors. Furthermore, sequences of ad hoc installations are subpar - instead specify through a YAML.

The following YAML file works just fine on linux-64, osx-64, and win-64 platforms:

so-igraph so-igraph.yaml

name: so-igraph
channels:
  - conda-forge
dependencies:
  - r-base=4.1  # adjust to desired version
  - r-shiny
  - r-visnetwork
  - r-dplyr
  - r-dt
  - r-igraph
  - r-leaflet
  - r-rgdal
  - r-shinydashboard
  - r-shinywidgets
  - r-shinycssloaders
  - r-igraph

Which can be used with

conda env create -n so-igraph -f so-igraph.yaml
conda activate so-igraph

I was having a similar problem with R on AlmaLinux, and it turned out I was missing some libraries on the OS itself, which I thought I had and that were necessary for some R packages. I think they were these, which makes sense, given that we're talking about igraph, a graphing package:

gsl-devel-2.5-1.el8.x86_64                     
gsl-2.5-1.el8.x86_64
openssl-1.1.1k-6.el8_5.x86_64
geos-devel-3.7.2-1.el8.x86_64                  
geos-3.7.2-1.el8.x86_64
proj-datumgrid-1.8-6.3.2.4.el8.noarch         
proj-6.3.2-4.el8.x86_64
libtiff-devel-4.0.9-21.el8.x86_64             
libgeotiff-devel-1.5.1-1.el8.x86_64           
libgeotiff-1.5.1-1.el8.x86_64
Related