3

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

  • conda overwrites library paths. This is how they make environments. Since you only work with R packages, I recommend using the docker image `rocker/shiny` instead. – danlooo Mar 31 '22 at 07:56
  • 1
    Can you [edit] your question and add the part of the error message that comes after the `unable to load shared object '/home/carlo/anaconda3/envs/r_env/lib/R/library/igraph/libs/igraph.so':` – FlyingTeller Mar 31 '22 at 10:06
  • 1
    @danlooo `conda overwrites library paths.` what do you mean exactly? Do you mean that it appends paths to environment variables used to locate libraries? How is that a bad thing and an argument against using it? – FlyingTeller Mar 31 '22 at 10:09
  • @FlyingTeller Conda is a third party community driven attempt to install libraries to many operating systems. They write shell scrips called recipes with specific environment variables and dependencies. Configuration of these recipes is very often broken. It is a highly complicated process. Authors usually only ensure that it works at CRAN. Doing docker you can have another R system. – danlooo Mar 31 '22 at 11:28
  • `DLLpath` can only work on Windows and not any Linux such as WSL2. If you have the conda env installed in power shell you can not use it in WSL2. – danlooo Mar 31 '22 at 11:30
  • Use `ldd` to list the dependencies of `igraph.so`, and make sure that they are present. A possible reason is that it is picking up an incompatible library. Since youre installing igraph from conda, presumably all the dependencies should come from conda as well. I have been the opposite problem where a system igraph picked up incompatible dependencies from conda. The solution was to deactivate the conda environments, which tend to cause these conflicts. Perhaps your conda igraph is picking up incompatible system versions of dependencies. – Szabolcs Mar 31 '22 at 13:28
  • 1
    @danlooo "*Configuration of these recipes is very often broken*" - I've been exclusively using Conda for R environment management for years and disagree with your assessment. Most missing library issues that users encounter are due to imprudent mixing of channels (which is the case here). While yes, Conda's strategy of modularizing all dependencies is complex, I'd ascribe root issue to poor communication of best practices to new users. I.e., users just need to follow some high-level rules to have a smooth experience, but old documentation from Anaconda/Continuum is still prominent. – merv Apr 01 '22 at 19:24
  • 1
    Thanks for the tip of not mixing channels! Since I also have lots of bioconda, mixing channels is quite common though... – danlooo Apr 01 '22 at 19:54
  • @danlooo the Conda Forge + Bioconda channel mixing is fine because they are configured to avoid overlaps between them. E.g., any packages submitted to Conda Forge automatically check for possible versions on Bioconda; Bioconda standards [exclude packages already available on Conda Forge](https://bioconda.github.io/contributor/guidelines.html#existing-package-exceptions). Since this is by design, I'd consider following [the Bioconda docs](http://bioconda.github.io/user/install.html#set-up-channels) a *prudent* mixing of channels. – merv Apr 01 '22 at 20:24

3 Answers3

2

(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
merv
  • 67,214
  • 13
  • 180
  • 245
  • 1
    Is it good practice to not specify the R version here explicitly? I always set the base R version e.g. to drastically reduce env solving durations. – danlooo Apr 01 '22 at 19:56
  • @danlooo yes, you're right - I also always specify version and consider it good practice to do so. I'll adjust. – merv Apr 01 '22 at 20:02
1

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
halfer
  • 19,824
  • 17
  • 99
  • 186
0

Installing openblas may work, see https://github.com/conda-forge/r-igraph-feedstock/issues/19

p.k
  • 11
  • 2
  • Even if this worked, I consider it a red herring and believe the post misidentifies the root cause. The Issue there similarly appears to involve imprudent mixing of channels. – merv Apr 04 '22 at 03:34