Cannot install igraph in R, problem with gfortran.

Hello,

Using an M1 Mac with Apple Silicon ARM chip, I can’t install properly igraph package in R.

The error seems to be related to the installation of gfortran…

Do you have any existing solution for this platform?

Thanks a lot for your help,

Gabriel

Why are you installing igraph from source? It seems from CRAN igraph that there are binaries available for macOS arm64.

If, for some reason you really do need to install from source, please see some specific instructions for installing from source here: How to compile R/igraph from source, with all features enabled? - #5 by szhorvat.

If you still can’t install igraph in R following these instructions, let us know. Please provide full details of the installation log, so that we know a bit what might be going on.

1 Like

Thanks a lot for your answer and sorry if my question was not clear enough. I’m not trying to install from source. I want to use a software called IRaMuTeQ for text analysis. It uses R language and for some functionalities, it needs to load igraph. The software itself is unable to do so.

So I went to RStudio and tried to install igraph with the command install.packages(‘igraph’). When I do so, I get an error message telling that loading failed. I don’t know what kind of information I can provide (the full log of the installation is very long…), but here is an extract with a reference to a problem with gfortran:

ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
installing to /Users/p2955/Library/R/x86_64/4.1/library/00LOCK-igraph/00new/igraph/libs
** R
** demo
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: le chargement du package ou de l'espace de noms a échoué pour ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...) :
impossible de charger l'objet partagé '/Users/p2955/Library/R/x86_64/4.1/library/00LOCK-igraph/00new/igraph/libs/igraph.so':
  dlopen(/Users/p2955/Library/R/x86_64/4.1/library/00LOCK-igraph/00new/igraph/libs/igraph.so, 0x0006): Library not loaded: @rpath/libxml2.2.dylib
  Referenced from: /Users/p2955/Library/R/x86_64/4.1/library/00LOCK-igraph/00new/igraph/libs/igraph.so
  Reason: tried: '/Library/Frameworks/R.framework/Resources/lib/libxml2.2.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/server/libxml2.2.dylib' (no such file)
Erreur : loading failed
Exécution arrêtée
ERROR: loading failed
* removing ‘/Users/p2955/Library/R/x86_64/4.1/library/igraph’
Warning in install.packages :
  installation of package ‘igraph’ had non-zero exit status

Maybe I mixed up a little bit things, because I’m working on an M1 ARM Apple machine, but RStudio itself and IRaMuTeQ are not optimized for ARM, they are Intel versions… so I was not very sure if I had to install Intel or ARM versions of the packages… Sorry for that.

Thanks a lot for helping,

Gabriel

Please follow these steps precisely:

  • Uninstall igraph if you have it installed.
  • Restart R.
  • install.packages("igraph")

Does it ask you if you want to install from source? What did you respond?

If it still fails, paste the full output.

I just noticed this. There are no binaries for igraph 1.3.1 on macOS/Intel yet. You can check when they become available here: CRAN - Package igraph

When you run install.packages("igraph"), it will ask you if you want to compile 1.3.1 from sources. Answer “no”, i.e. choose to install the 1.3.0 binary release.

This advice applies to all R packages. If you are not experienced compiling packages from source, always answer “no” to this question.

Great, thanks a lot @szhorvat!

I was accepting to install the newest version from source… So I answered «no» and then it could install properly!

Problem solved!

Thanks a lot for helping and sorry for bothering you,

Gabriel

3 Likes