kharchenkolab/leidenAlg

Installation on MacOS not successful

Closed this issue · 14 comments

Hi, hanks for this great package! I cant seem to install it on a Mac though. Here is the sessionInfo and the errors.

  • Session info

sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] igraph_1.2.6 Matrix_1.3-3

loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 lattice_0.20-44 png_0.1-7 shinyWidgets_0.6.0 assertthat_0.2.1 rprojroot_2.0.2
[7] digest_0.6.27 utf8_1.2.1 mime_0.10 R6_2.5.0 plyr_1.8.6 evaluate_0.14
[13] ggplot2_3.3.3 pillar_1.6.0 rlang_0.4.11 sortable_0.4.4 jquerylib_0.1.4 learnr_0.10.1
[19] sccore_0.1.3 reticulate_1.20 grr_0.9.5 rmarkdown_2.8 stringr_1.4.0 htmlwidgets_1.5.3
[25] munsell_0.5.0 tinytex_0.31 shiny_1.6.0 compiler_4.0.5 httpuv_1.6.1 xfun_0.22
[31] pkgconfig_2.0.3 clipr_0.7.1 htmltools_0.5.1.1 tidyselect_1.1.1 tibble_3.1.1 gridExtra_2.3
[37] dendextend_1.15.1 fansi_0.4.2 viridisLite_0.4.0 withr_2.4.2 crayon_1.4.1 dplyr_1.0.6
[43] later_1.2.0 Matrix.utils_0.9.8 grid_4.0.5 jsonlite_1.7.2 xtable_1.8-4 gtable_0.3.0
[49] lifecycle_1.0.0 DBI_1.1.1 magrittr_2.0.1 scales_1.1.1 stringi_1.5.3 reshape2_1.4.4
[55] viridis_0.6.1 promises_1.2.0.1 bslib_0.2.4 ellipsis_0.3.2 generics_0.1.0 vctrs_0.3.8
[61] RColorBrewer_1.1-2 tools_4.0.5 glue_1.4.2 markdown_1.1 purrr_0.3.4 shinycssloaders_1.0.0
[67] parallel_4.0.5 fastmap_1.1.0 yaml_2.2.1 colorspace_2.0-1 knitr_1.33 sass_0.3.1

  • Installing from cran works fine but package will not load:

library(leidenAlg)
Loading required package: Matrix
Loading required package: igraph

Attaching package: ‘igraph’

The following objects are masked from ‘package:stats’:

decompose, spectrum

The following object is masked from ‘package:base’:

union

Error: package or namespace load failed for ‘leidenAlg’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/leidenAlg/libs/leidenAlg.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/leidenAlg/libs/leidenAlg.so, 6): Library not loaded: @rpath/igraph.so
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/leidenAlg/libs/leidenAlg.so
Reason: image not found

  • Installing from github crashes before even loading. This is not the full console output, i think this is the relevant parts

devtools::install_github('kharchenkolab/leidenAlg', build_vignettes = TRUE)
Downloading GitHub repo kharchenkolab/leidenAlg@HEAD
✓ checking for file ‘/private/var/folders/sy/gp7_zd0918j429vrk56lxvgw0000gn/T/RtmpOElSu6/remotes5c113b358a16/kharchenkolab-leidenAlg-0db1cdf/DESCRIPTION’ ...

  • Some warnings, this is the last messages

Attaching package: ‘igraph’

The following objects are masked from ‘package:stats’:

decompose, spectrum

The following object is masked from ‘package:base’:

union

clang++ -mmacosx-version-min=10.13 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -o leidenAlg.so RcppExports.o leiden.o -L/usr/lib/ -L. -lpthread -lstdc++ -lleidenalg -lm -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm /Library/Frameworks/R.framework/Versions/4.0/Resources/library/igraph/libs/igraph.so -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation

Attaching package: ‘igraph’

The following objects are masked from ‘package:stats’:

decompose, spectrum

The following object is masked from ‘package:base’:

union

ld: warning: directory not found for option '-L/usr/local/opt/gettext/lib'
ld: warning: directory not found for option '-L/usr/local/opt/llvm/lib'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [leidenAlg.so] Error 1
ERROR: compilation failed for package ‘leidenAlg’

  • removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/leidenAlg’
  • restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/leidenAlg’
    Warning message:
    In i.p(...) :
    installation of package ‘/var/folders/sy/gp7_zd0918j429vrk56lxvgw0000gn/T//RtmpOElSu6/file5c1134ddc4bf/leidenAlg_0.1.1.tar.gz’ had non-zero exit status

Thanks for any and all help!
Best

Hi @leonidaslundell

Others mentioned a problem recently as well: #4

I've found it difficult to reproduce this issue on my own Mac OS. Also, the Mac OS binaries build correctly on CRAN: https://cran.r-project.org/web/packages/leidenAlg/index.html

(1) Check that you have the external libraries installed for igraph: https://igraph.org/r/

I believe for Mac OS, the following will work:

brew update
brew install libxml2 glpk gmp

but it's possible that I'm missing a dependency. This is my best guess regarding what's going on.

(2) Install from CRAN, with install.packages()

(3) If that doesn't work, try this: https://github.com/kharchenkolab/leidenAlg/wiki/Installing-leidenAlg-for-Mac-OS

Based on the logs above, you don't have gfortran installed, etc.

Otherwise, I'm stumped. If there's still a problem, I could try outsourcing the issue to the R community. But I don't have a lot of insight here locally, as I cannot reproduce the issues on Mac OS.

Hi @evanbiederstedt

Thanks for the reply and sorry for the duplicated question.

I tried all your suggestions and they did not seem to work.

I did manage to install and run though:

git clone https://github.com/kharchenkolab/leidenAlg.git
cd leidenAlg
R CMD build .
sudo R CMD install leidenAlg*.tar.gz

Hi @leonidaslundell

That's reasonable---I often install packages via

git clone https://github.com/kharchenkolab/leidenAlg.git
cd leidenAlg
R CMD build .
R CMD install leidenAlg*.tar.gz

I still haven't been able to replicate this issue with an isolated Mac OS environment...I'll keep checking of course.

It's good the above installs, as this means there isn't something flawed in the Makevars file. Thanks!

Hi @evanbiederstedt,

Sorry for not highlighting it but for the package loading to work i needed to include the sudo! Ie. sudo R CMD install leidenAlg*.tar.gz. Without sudo it did not work.

Reason i tried the sudo was that i saw Permission denied warnings on a different machine that i was testing on. Find attached the error log below.

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't open input file: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/igraph/libs/igraph.so for writing (Permission denied) error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't lseek to offset: 0 in file: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/igraph/libs/igraph.so for writing (Bad file descriptor) error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't write new headers in file: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/igraph/libs/igraph.so (Bad file descriptor) error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't close written on input file: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/igraph/libs/igraph.so (Bad file descriptor) make: *** [all] Error 1 ERROR: compilation failed for package ‘leidenAlg’ * removing ‘/Users/xjp391/Library/R/4.0/library/leidenAlg’ Error: Failed to install 'leidenAlg' from GitHub: (converted from warning) installation of package ‘/var/folders/fq/m6jy3d7d6wl2jly92nrr3hy9tyht7r/T//Rtmp392ZNI/file3c4578570c1/leidenAlg_0.1.1.tar.gz’ had non-zero exit status > >

Cheers

Sounds like the issue is that the shared libraries in R within /Library/Frameworks/R.framework/Versions/4.0/Resources/library/ have permissions which are excessively restrictive:

e.g. https://stackoverflow.com/questions/67344090/install-name-tool-cant-open-input-file-dylib-for-writing-permission-denied

You might try ls -lh /Library/Frameworks/R.framework/Versions/4.0/Resources/library/igraph/libs/igraph.so to double check this.

I'm guessing this is on your personal Mac OS, so you should probably use chmod to change the permissions e.g. https://kb.iu.edu/d/abdb

Yeah that makes sense. Default permissions are -rwxr-xr-x for igraph. I will keep this in mind if i get similar issues in the future. Perhaps the issues discussed in the other thread can also be solved with like this?

Thank you again for your great work, and thank you for all the rapid responses!

Hi, I'm trying this with a slightly non-standard library location and running into problems. This works ok:

git clone https://github.com/kharchenkolab/leidenAlg.git
cd leidenAlg
R CMD build .

The install call gets me these errors:

R CMD install leidenAlg*.tar.gz
# * installing to library ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library’
# ERROR: dependencies ‘Matrix.utils’, ‘Rcpp’, ‘sccore’, ‘RcppArmadillo’, ‘RcppEigen’ are not available for package ‘leidenAlg’
# * removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/leidenAlg’

so I add the library path, which gets me "cannot change working directory" errors:

R CMD install -l /Users/macnairw/lib/R/R4.1.3 leidenAlg*.tar.gz
# ** checking absolute paths in shared objects and dynamic libraries
# Fehler in setwd(startdir) : kann Arbeitsverzeichnis nicht wechseln
# * restoring previous ‘/Users/macnairw/lib/R/R4.1.3/leidenAlg’
# Fehler in setwd(startdir) : kann Arbeitsverzeichnis nicht wechseln
# Ausführung angehalten

It should be possible to install this with dependencies in a non-default library directory, right? Any idea what might be the problem?

Thanks!
Will

I've now tried via devtools::install_github("kharchenkolab/leidenAlg"), and the installation is fine, but then when I call library('leidenAlg') I get

Error: package or namespace load failed for ‘leidenAlg’ in get(method, envir = home):
 lazy-load database '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/leidenAlg/R/leidenAlg.rdb' is corrupt

Things I have tried from your MacOS troubleshooting page:

  • libxml2 is installed
  • igraph seems to work fine (I can load the library and simple examples work)
  • I've done install_name_tool -id '@rpath/igraph.so' /Library/Frameworks/R.framework/Versions/4.1/Resources/library/igraph/libs/igraph.so
  • I tried devtools::install_github('kharchenkolab/leidenAlg')
  • As detailed above, I tried git clone https://github.com/kharchenkolab/leidenAlg.git etc

My sessionInfo:

> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur/Monterey 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] C/UTF-8/C/C/C/C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] igraph_1.2.11 Matrix_1.4-0

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.2   remotes_2.4.2      purrr_0.3.4        lattice_0.20-45
 [5] colorspace_2.0-3   vctrs_0.3.8        generics_0.1.2     testthat_3.1.2
 [9] usethis_2.1.5      sccore_1.0.1       utf8_1.2.2         rlang_1.0.2
[13] pkgbuild_1.3.1     pillar_1.7.0       glue_1.6.2         withr_2.5.0
[17] DBI_1.1.2          sessioninfo_1.2.2  lifecycle_1.0.1    munsell_0.5.0
[21] Matrix.utils_0.9.8 gtable_0.3.0       devtools_2.4.3     memoise_2.0.1
[25] callr_3.7.0        fastmap_1.1.0      ps_1.6.0           parallel_4.1.3
[29] curl_4.3.2         fansi_1.0.2        Rcpp_1.0.8.3       scales_1.1.1
[33] cachem_1.0.6       grr_0.9.5          desc_1.4.1         pkgload_1.2.4
[37] fs_1.5.2           brio_1.1.3         ggplot2_3.3.5      processx_3.5.2
[41] dplyr_1.0.8        grid_4.1.3         rprojroot_2.0.2    cli_3.2.0
[45] tools_4.1.3        magrittr_2.0.2     tibble_3.1.6       crayon_1.5.0
[49] pkgconfig_2.0.3    ellipsis_0.3.2     prettyunits_1.1.1  assertthat_0.2.1
[53] R6_2.5.1           compiler_4.1.3

Hi @wmacnair

For this:

R CMD install leidenAlg*.tar.gz
# * installing to library ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library’
# ERROR: dependencies ‘Matrix.utils’, ‘Rcpp’, ‘sccore’, ‘RcppArmadillo’, ‘RcppEigen’ are not available for package ‘leidenAlg’
# * removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/leidenAlg’

The easiest way to fix this would be to install the dependencies: Matrix.utils, sccore, Rcpp, RcppArmadillo, RcppEigen. I manually do this, but there are discussions elsewhere for simplifying this, e.g. install_deps(): https://stackoverflow.com/questions/6907937/how-to-install-dependencies-when-using-r-cmd-install-to-install-r-packages

RE:

Fehler in setwd(startdir) : kann Arbeitsverzeichnis nicht wechseln

That is, Error in setwd(startdir) : cannot change working directory . It's a standard setwd() error.
https://r-forge.r-project.org/tracker/?func=detail&aid=2395&group_id=34&atid=194
https://stackoverflow.com/questions/33692296/having-trouble-setting-working-directory

I'm guessing you're getting it due to permissions issues, e.g. you don't own the paths above.

RE:

Error: package or namespace load failed for ‘leidenAlg’ in get(method, envir = home):
lazy-load database '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/leidenAlg/R/leidenAlg.rdb' is corrupt

If you google this, restarting R almost always fixes the problem.

Big picture:

The package is on CRAN. It builds for all operating systems:
https://cran.r-project.org/web/packages/leidenAlg/index.html
https://cran.r-project.org/web/checks/check_results_leidenAlg.html

Hello @evanbiederstedt and the Team,

I am trying to install Conos and leidenAlg and I'm bumping into a serious roadblock that seem to belong to this subject. However, my error is a tiny bit different when I try to install the package.
I tried to install it directly from CRAN using:
install.packages("leidenAlg")

and also by downloading the leidenAlg_1.0.3.tar.gz to my laptop (MacOS) and choosing the file manually:
install.packages(file.choose(), repos=NULL)

Both of the methods gave me the following error message:

...
In file included from core/isomorphism/bliss.cc:20:
In file included from core/isomorphism/bliss/graph.hh:35:
In file included from core/isomorphism/bliss/stats.hh:24:
In file included from core/isomorphism/bliss/bignum.hh:26:
core/isomorphism/bliss/../../internal/gmp_internal.h:31:10: fatal error: 'gmp.h' file not found
#include <gmp.h>
^~~~~~~
1 error generated.
make[1]: *** [core/isomorphism/bliss.o] Error 1
make: *** [sublibraries] Error 1
ERROR: compilation failed for package ‘leidenAlg’

  • removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/leidenAlg’
  • restoring previous ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/leidenAlg’
    Warning in install.packages :
    installation of package ‘/Users/michallipinski/Downloads/leidenAlg_1.0.3.tar.gz’ had non-zero exit status

I'm struggling to find any info about "core/isomorphism/bliss.o" and would appreciate any suggestion!

Here is my sessionInfo:

R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.3.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] igraph_1.3.0 cacoa_0.3.0 Matrix_1.4-1 devtools_2.4.3 usethis_2.1.5

loaded via a namespace (and not attached):
[1] tidyselect_1.1.2 remotes_2.4.2 reshape2_1.4.4 purrr_0.3.4 lattice_0.20-45 colorspace_2.0-3
[7] vctrs_0.4.1 generics_0.1.2 testthat_3.1.3 sccore_1.0.1 utf8_1.2.2 rlang_1.0.2
[13] pkgbuild_1.3.1 pillar_1.7.0 glue_1.6.2 withr_2.5.0 DBI_1.1.2 sessioninfo_1.2.2
[19] plyr_1.8.7 lifecycle_1.0.1 stringr_1.4.0 Matrix.utils_0.9.8 munsell_0.5.0 gtable_0.3.0
[25] memoise_2.0.1 forcats_0.5.1 callr_3.7.0 fastmap_1.1.0 ps_1.6.0 curl_4.3.2
[31] parallel_4.1.2 fansi_1.0.3 Rcpp_1.0.8.3 scales_1.2.0 BiocManager_1.30.16 cachem_1.0.6
[37] grr_0.9.5 desc_1.4.1 pkgload_1.2.4 fs_1.5.2 brio_1.1.3 gridExtra_2.3
[43] ggplot2_3.3.5 stringi_1.7.6 processx_3.5.3 dplyr_1.0.8 cowplot_1.1.1 grid_4.1.2
[49] rprojroot_2.0.3 cli_3.2.0 tools_4.1.2 magrittr_2.0.3 tibble_3.1.6 crayon_1.5.1
[55] ape_5.6-2 pkgconfig_2.0.3 ellipsis_0.3.2 data.table_1.14.2 prettyunits_1.1.1 assertthat_0.2.1
[61] rstudioapi_0.13 R6_2.5.1 nlme_3.1-157 compiler_4.1.2

Thanks,
Michal

Hi @michallipinski

fatal error: 'gmp.h' file not found
#include <gmp.h>
^~~~~~~
1 error generated.

This error means it cannot find the required system libraries for the package.

We tried to detail this here:

https://github.com/kharchenkolab/leidenAlg#installation

You need to install libxml2, glpk, gmp. I'd recommend using brew.

For Mac OS users, please run:

brew update
brew install libxml2 glpk gmp

Thanks, Evan

Hi Evan,

Thanks so much for your quick response and I'm sorry I missed that part of installation.
Unfortunately this didn't solve my problem and after restarting the R session I get exactly the same error. Do I need to add the gmp to the path or something?

Thanks,
Michal

Hi @michallipinski

So, we updated this package on CRAN a few days ago. It takes CRAN a while for the binary of the package to be created and hosted on CRAN: https://cran.r-project.org/web/packages/leidenAlg/index.html

You're currently installing the package from scratch, not using the binary (as it's not accessible yet via CRAN).

One approach might be to wait until the binary is available. It should be another 24-72 hours.

In terms of GMP: this is a really standard systems library. The full name is the "GNU Multiple Precision Arithmetic Library".

https://en.wikipedia.org/wiki/GNU_Multiple_Precision_Arithmetic_Library
https://formulae.brew.sh/formula/gmp

If you want to try compiling the package leidenAlg, please follow this section: https://github.com/kharchenkolab/leidenAlg/wiki/Installing-leidenAlg-for-Mac-OS#installing-from-sourceIn

To explain this a bit, the Makevars file in this package actually compiles C/C++ code. In your case, it's not finding the library GMP and thus there's a compilation error.

Assuming your brew works the same as mine, you'll find gmp here:

/usr/local/opt/gmp

It might be worth trying this:

export PATH="/usr/local/opt/gmp:$PATH"
export LDFLAGS="-L/usr/local/opt/gmp/lib"
export CPPFLAGS="-I/usr/local/opt/gmp/include"

I should probably update the instructions here: https://github.com/kharchenkolab/leidenAlg/wiki/Installing-leidenAlg-for-Mac-OS

We put this on CRAN to build the binaries, precisely so Mac OS users don't have to go through this compilation pain.

Hopefully this helps.

Best, Evan

Hi Evan,
I've waited a little bit and now the problem has resolved itself with the regular installation ( install.packages() )

Thanks!
Michal