# Cannot install igraph in R, problem with gfortran.

**URL:** <https://igraph.discourse.group/t/cannot-install-igraph-in-r-problem-with-gfortran/1192>\
**Category:** Installation\
**Tags:** R\
**Created:** [21 April 2022 09:34 UTC](https://igraph.discourse.group/t/cannot-install-igraph-in-r-problem-with-gfortran/1192 "2022-04-21T09:34:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriel.parriaux](https://avatars.discourse-cdn.com/v4/letter/g/958977/32.png) [@gabriel.parriaux](https://igraph.discourse.group/u/gabriel.parriaux)\
**Post date:** [21 April 2022 09:34 UTC](https://igraph.discourse.group/t/cannot-install-igraph-in-r-problem-with-gfortran/1192/1 "2022-04-21T09:34:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vtraag](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/vtraag/32/38_2.png) [@vtraag](https://igraph.discourse.group/u/vtraag)\
**Post date:** [21 April 2022 10:33 UTC](https://igraph.discourse.group/t/cannot-install-igraph-in-r-problem-with-gfortran/1192/2 "2022-04-21T10:33:36Z")

</div>

Why are you installing `igraph` from source? It seems from [CRAN igraph](https://cran.r-project.org/web/packages/igraph/index.html) 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](https://igraph.discourse.group/t/how-to-compile-r-igraph-from-source-with-all-features-enabled/1190/5).

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.

---

<div class="post-metadata">

**Author:** ![gabriel.parriaux](https://avatars.discourse-cdn.com/v4/letter/g/958977/32.png) [@gabriel.parriaux](https://igraph.discourse.group/u/gabriel.parriaux)\
**Post date:** [21 April 2022 11:33 UTC](https://igraph.discourse.group/t/cannot-install-igraph-in-r-problem-with-gfortran/1192/3 "2022-04-21T11:33:45Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [21 April 2022 11:44 UTC](https://igraph.discourse.group/t/cannot-install-igraph-in-r-problem-with-gfortran/1192/4 "2022-04-21T11:44:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [21 April 2022 11:51 UTC](https://igraph.discourse.group/t/cannot-install-igraph-in-r-problem-with-gfortran/1192/5 "2022-04-21T11:51:25Z")

</div>

> [@gabriel.parriaux](#):
>
> but RStudio itself and IRaMuTeQ are not optimized for ARM, they are Intel versions

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](https://cran.r-project.org/web/packages/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.

 ![image](https://global.discourse-cdn.com/free1/uploads/igraph/original/1X/187b544e3111450388400b03d307ae943178f076.png)

---

<div class="post-metadata">

**Author:** ![gabriel.parriaux](https://avatars.discourse-cdn.com/v4/letter/g/958977/32.png) [@gabriel.parriaux](https://igraph.discourse.group/u/gabriel.parriaux)\
**Post date:** [21 April 2022 12:03 UTC](https://igraph.discourse.group/t/cannot-install-igraph-in-r-problem-with-gfortran/1192/6 "2022-04-21T12:03:06Z")

</div>

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
