I use R 4.3.3 in a micromamba environment. install.packages('igraph') currently gives me:
/zi/home/johannes.wiesner/micromamba/envs/project_mase/bin/../lib/gcc/x86_64-conda-linux-gnu/14.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: cannot find -llzma: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [/zi/home/johannes.wiesner/micromamba/envs/project_mase/lib/R/share/make/shlib.mk:10: igraph.so] Error 1
ERROR: compilation failed for package ‘igraph’
* removing ‘/zi/home/johannes.wiesner/micromamba/envs/project_mase/lib/R/library/igraph’
The downloaded source packages are in
‘/tmp/RtmpwRWNlz/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("igraph") :
installation of package ‘igraph’ had non-zero exit status
Here’s my R version:
> version
_
platform x86_64-conda-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 4
minor 3.3
year 2024
month 02
day 29
svn rev 86002
language R
version.string R version 4.3.3 (2024-02-29)
nickname Angel Food Cake
Strange enough, only a few weeks ago I also installed igraph in another micromamba environment and everything worked. Here, igraph was installed automatically as a dependency of brainGraph:
> packageVersion("igraph")
[1] ‘2.0.3’
> packageVersion("brainGraph")
[1] ‘3.1.0’
> version
_
platform x86_64-conda-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 4
minor 3.3
year 2024
month 02
day 29
svn rev 86002
language R
version.string R version 4.3.3 (2024-02-29)
nickname Angel Food Cake
To explain what is going on, if you use a conda environment (mamba is the same as conda, just a faster installer), it attempts to compartmentalise everything away from the rest of the operating system. That is, it installs its own libraries for everything, and tries to ensure that everything operates nicely with each other. When installing something using conda or mamba, it also installs the necessary system libraries along with it.
In contrast, when running install.pacakges (or something like pip install for Python), it does not automatically install system libraries. The required libraries are presumably already installed on your system elsewhere, but since the conda environment is completely compartmentalised, these libraries cannot be found from within the environment. This is the whole purpose of conda, and so that should stay that way.
Therefore, the required system dependencies should be installed using conda or mamba. In this specific case, the requirement was libzma, but there may have been other system dependencies missing still. When installing igraph (the C core library of igraph) using conda, it automatically installs all necessary system dependencies for igraph as well. You can then install the igraph R package as usual using install.packages from within R. Alternatively, you can install igraph using conda by installing r-igraph.
Hopefully this is useful in understanding a bit how this works.
Hey @vtraag thanks for the explanation. Yeah, the whole problem is in the upstream because I am mainly interested in installing the package brainGraph which cannot be installed using conda. Lessons learned:
1.) Install all dependencies using conda.
2.) Install the package of interest using package.install(‘package_name’,dependencies=FALSE)