Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

igraph failing to compile due to missing libgfortran.so.4 (Arch based Linux) #275

Closed
OscarSouth opened this issue May 22, 2018 · 86 comments
Closed

Comments

@OscarSouth
Copy link

OscarSouth commented May 22, 2018

A broken dependency for igraph is preventing me from installing many R libraries which depend on igraph.

I attempted to install with install.packages() and with devtools, both failed in same manner:

** testing if installed package can be loaded
Error: package or namespace load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/oscarsouth/R/x86_64-pc-linux-gnu-library/3.5/igraph/libs/igraph.so':
  libgfortran.so.4: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/oscarsouth/R/x86_64-pc-linux-gnu-library/3.5/igraph’
Installation failed: Command failed (1)

libgfortran.so.5 is showing up here:

$ lddtree /usr/lib64/R/bin/exec/R
/usr/lib64/R/bin/exec/R (interpreter => /lib64/ld-linux-x86-64.so.2)
    libR.so => /usr/lib/R/lib/libR.so
        libblas.so.3 => /lib64/libblas.so.3
            libgfortran.so.5 => /lib64/libgfortran.so.5
                libquadmath.so.0 => /usr/lib/libquadmath.so.0
                libgcc_s.so.1 => /usr/lib/libgcc_s.so.1

R version 3.5.0 (2018-04-23)
gcc (GCC) 8.1.0

I've tried all the solutions I can find from Google. Is there any solution to this at present?

Thanks!

@OscarSouth
Copy link
Author

Haven't had any luck solving this. Is it an issue with the igraph lib, or with R itself? (I've been able to install other packages successfully, however)

@OscarSouth
Copy link
Author

> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Manjaro Linux

Matrix products: default
BLAS/LAPACK: /usr/lib/libopenblas_sandybridgep-r0.2.20.so

locale:
 [1] LC_CTYPE=en_GB.utf8        LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.utf8     
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.utf8    
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

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

loaded via a namespace (and not attached):
[1] compiler_3.5.0
> 

@alexperrone
Copy link

alexperrone commented May 24, 2018 via email

@OscarSouth
Copy link
Author

OscarSouth commented May 24, 2018

Thanks for the assistance.

I made sure that it’s installed on my system (as you say, it’s included with gcc, and I also double checked carefully).

I think that the issue is that gcc 8 bumped it up from libgfortran.so.4 to libgfortran.so.5 and igraph has a dependency on the former.

Since the newer dependency isn’t fulfilling the requirement and downgrading gcc isn’t exactly a good idea, I can’t see an easy solution.

I could be wrong about this, but from a few hours of unsuccessful troubleshooting, this is what it looks like to me.

Not sure if it’s something to fix on my end or a case of waiting for an igraph update that fixes the dependency.

@OscarSouth OscarSouth changed the title igraph failing to compile due to missing libgfortran.so.4 (Manjaro Linux) igraph failing to compile due to missing libgfortran.so.4 (Arch Linux) May 29, 2018
@OscarSouth OscarSouth changed the title igraph failing to compile due to missing libgfortran.so.4 (Arch Linux) igraph failing to compile due to missing libgfortran.so.4 (Arch based Linux) May 29, 2018
@cramjaco
Copy link

cramjaco commented Jun 8, 2018

I have essentially this same problem with ubuntu based linux 16.04. Can confirm that I have gfortran installed, as well as all of the dependencies for devtools, but when I run: devtools::install_github("igraph/rigraph") I also get the very similar error


> installing to /home/ohnoplus/R/i686-pc-linux-gnu-library/3.2/igraph/libs
> ** R
> ** demo
> ** inst
> ** preparing package for lazy loading
> ** help
> *** installing help indices
> ** building package indices
> ** testing if installed package can be loaded
> Error in dyn.load(file, DLLpath = DLLpath, ...) : 
>   unable to load shared object '/home/ohnoplus/R/i686-pc-linux-gnu-library/3.2/igraph/libs/igraph.so':
>   libgfortran.so.4: cannot open shared object file: No such file or directory
> Error: loading failed
> Execution halted
> ERROR: loading failed
> * removing ‘/home/ohnoplus/R/i686-pc-linux-gnu-library/3.2/igraph’
> Installation failed: Command failed (1)

I also am unable to use igraph or install anything that depends on igraph in this case.

@ShotaOchi
Copy link

I had the same problem on Manjaro Linux.
The problem was resolved by installing gcc-fortran.
In other words, "igraph" was successfully installed after typing "pacman -S gcc-fortran".
I hope this information will help you.

@OscarSouth
Copy link
Author

@ShotaOchi Thanks but in this case the issue is caused by a mismatched version dependency — gcc-fortran comes with libgfortran.so.5 while igraph requires the outdated libgfortran.so.4 which is not provided by the up to date gcc-fortran version.

@gaborcsardi
Copy link
Contributor

while igraph requires the outdated libgfortran.so.4

no, it does not. igraph works with any version.

@gaborcsardi
Copy link
Contributor

@OscarSouth I think you have a broken installation. Your R installation was built with libgfortran.so.5 and your igraph installation or package was built with libgfortran.so.4.

Did you compile igraph yourself? Then you need to re-install (=recompile) it from the source R package.

If you installed it from a binary package provided by your platform, then that package is broken, see if there is a new version of it, or install from the source R package.

@OscarSouth
Copy link
Author

OscarSouth commented Jun 18, 2018

@gaborcsardi Thanks for the insight here. The discussion available through google search is a bit misleading on this issue if that is the case.

I installed R from repository using the pacman command and attempted to install igraph with the install.packages() tool inside R. Is this what you mean by the source R package, or should I attempt to install it by another method?

@gaborcsardi
Copy link
Contributor

gaborcsardi commented Jun 18, 2018

Yes, then you built from a source package, so I am not sure why it was broken. I would try to just re-install it.

You can use the --no-clean-on-error option, that keeps the installed package, even if you can't load it:

install.packages("igraph", INSTALL_opts = "--no-clean-on-error")

and then try to load it:

library(igraph)

If loading fails, check which libs the igraph shared lib links to:

ldd /home/oscarsouth/R/x86_64-pc-linux-gnu-library/3.5/igraph/libs/igraph.so

@OscarSouth
Copy link
Author

OscarSouth commented Jun 18, 2018

Thanks for the assistance. This is the results of install.packages("igraph", INSTALL_opts = "--no-clean-on-error"):

Error: package or namespace load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/oscarsouth/R/x86_64-pc-linux-gnu-library/3.5/igraph/libs/igraph.so':
  libgfortran.so.4: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed

The downloaded source packages are in
	‘/tmp/RtmpUFicvj/downloaded_packages’
Warning message:
In install.packages("igraph", INSTALL_opts = "--no-clean-on-error") :
  installation of package ‘igraph’ had non-zero exit status

This is the results of > library(igraph):

Error: package or namespace load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/oscarsouth/R/x86_64-pc-linux-gnu-library/3.5/igraph/libs/igraph.so':
  libgfortran.so.4: cannot open shared object file: No such file or directory

This is the results of ldd /home/oscarsouth/R/x86_64-pc-linux-gnu-library/3.5/igraph/libs/igraph.so:

	linux-vdso.so.1 (0x00007ffedbbea000)
	libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00007f030292f000)
	libgmp.so.10 => /usr/lib/libgmp.so.10 (0x00007f030269c000)
	libopenblas.so.0 => /usr/lib/libopenblas.so.0 (0x00007f0301737000)
	libgfortran.so.4 => not found
	libm.so.6 => /usr/lib/libm.so.6 (0x00007f03013a2000)
	libR.so => /usr/lib/R/lib/libR.so (0x00007f0300d1e000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f0300995000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f030077d000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f03003c1000)
	libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f03001bd000)
	libicuuc.so.61 => /usr/lib/libicuuc.so.61 (0x00007f02ffe03000)
	libz.so.1 => /usr/lib/libz.so.1 (0x00007f02ffbec000)
	liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007f02ff9c6000)
	libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f02ff7a8000)
	libgfortran.so.5 => /usr/lib/libgfortran.so.5 (0x00007f02ff32e000)
	/usr/lib64/ld-linux-x86-64.so.2 (0x00007f03031da000)
	libreadline.so.7 => /usr/lib/libreadline.so.7 (0x00007f02ff0e1000)
	libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007f02fee6f000)
	libbz2.so.1.0 => /usr/lib/libbz2.so.1.0 (0x00007f02fec5f000)
	librt.so.1 => /usr/lib/librt.so.1 (0x00007f02fea57000)
	libicui18n.so.61 => /usr/lib/libicui18n.so.61 (0x00007f02fe5ac000)
	libgomp.so.1 => /usr/lib/libgomp.so.1 (0x00007f02fe37e000)
	libicudata.so.61 => /usr/lib/libicudata.so.61 (0x00007f02fc7d9000)
	libquadmath.so.0 => /usr/lib/../lib/libquadmath.so.0 (0x00007f02fc598000)
	libncursesw.so.6 => /usr/lib/libncursesw.so.6 (0x00007f02fc32b000)

@gaborcsardi
Copy link
Contributor

I think either you have an older gfortran on your system, or some other library links to libgfortran.so.4.

@OscarSouth
Copy link
Author

OscarSouth commented Jun 18, 2018

@gaborcsardi I did some exploration into that when I first experienced this issue. As far as I can tell based on what I can determine from my system and the experience I could uncover of others who've had similar issues, it's because igraph expects an earlier version of libgfortran than the most up to date gcc distribution provides.

$ lddtree /usr/lib64/R/bin/exec/R
/usr/lib64/R/bin/exec/R (interpreter => /lib64/ld-linux-x86-64.so.2)
    libR.so => /usr/lib/R/lib/libR.so
        libblas.so.3 => /lib64/libblas.so.3
            libgfortran.so.5 => /lib64/libgfortran.so.5
                libquadmath.so.0 => /usr/lib/libquadmath.so.0
                libgcc_s.so.1 => /usr/lib/libgcc_s.so.1

I read into gcc and the dependencies that it provides and libgfortran.so.4 is not included in the newer versions of gcc. That's as deep as I managed to go on personal exploration and intuition.

The only solutions that I could find presented were suggestions to downgrade an earlier version of gcc which provides the earlier version of libgfortran that igraph is asking for here, but I expect that would cause a lot more troubles than it'd solve.

@gaborcsardi
Copy link
Contributor

because igraph expects an earlier version of libgfortran than the most up to date gcc distribution provides.

I am still not sure why you think that. It is definitely not the case.

I think you might have an earlier libgfortran lying around, e.g. from another package, and R finds that one while installing igraph, but then it does not find it while you are loading it.

@OscarSouth
Copy link
Author

@gaborcsardi I’m definitely not convinced on that situation, that’s just the most realistic I got from the related stack overflow questions that I read on it. I’m glad to hear another perspective and a potential opportunity to solve the issue.

Do you know of any way I can check for the existence of the situation which you propose? (Or solve it)

Thanks for the help so far, much appreciated

@gaborcsardi
Copy link
Contributor

Look for libgfortran* files on you machine.

@OscarSouth
Copy link
Author

OscarSouth commented Jun 18, 2018

Pulled at this string and finally managed to get it to install by creating a .R/Makevars file with the following lines:

#F77 = /usr/bin/gfortran
#FC = $F77
#FLIBS = -L/usr/bin/gfortran

then running

library(devtools)
install_github("igraph/rigraph")

Cheers for pointing me in the right direction!

@cls3415
Copy link

cls3415 commented Jul 20, 2018

Hi @OscarSouth, may I know where I should create .R/Makevars?
Thanks!

@danielee0707
Copy link

Same problem here on Arch, still not solved unless I preload libgfortran.so.4 from some other places first or softlink one

@danielee0707
Copy link

danielee0707 commented Jul 28, 2018

Solved by renaming libgfortran.so.4.0.0 in the local anaconda3 directory to something else, and recompile

        linux-vdso.so.1 (0x00007ffc454aa000)  
        libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00007f156239e000)  
        libgmp.so.10 => /usr/lib/libgmp.so.10 (0x00007f156210b000)  
        libopenblas.so.0 => /usr/lib/libopenblas.so.0 (0x00007f1561177000)  
        libgfortran.so.5 => /usr/lib/libgfortran.so.5 (0x00007f1560cfd000)  
        libm.so.6 => /usr/lib/libm.so.6 (0x00007f1560968000)  
        libR.so => /usr/lib/R/lib/libR.so (0x00007f15602e4000)  
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f155ff5b000)  
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f155fd43000)  
        libc.so.6 => /usr/lib/libc.so.6 (0x00007f155f987000)  
        libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f155f783000)  
        libicuuc.so.61 => /usr/lib/libicuuc.so.61 (0x00007f155f3c9000)  
        libz.so.1 => /usr/lib/libz.so.1 (0x00007f155f1b2000)  
        liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007f155ef8c000)  
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f155ed6e000)  
        libquadmath.so.0 => /usr/lib/../lib/libquadmath.so.0 (0x00007f155eb2d000)  
        /usr/lib64/ld-linux-x86-64.so.2 (0x00007f1562c49000)  
        libblas.so.3 => /usr/lib/libblas.so.3 (0x00007f155e8d9000)  
        libreadline.so.7 => /usr/lib/libreadline.so.7 (0x00007f155e68c000)  
        libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007f155e41a000)  
        libbz2.so.1.0 => /usr/lib/libbz2.so.1.0 (0x00007f155e20a000)  
        libtirpc.so.3 => /usr/lib/libtirpc.so.3 (0x00007f155dfd9000)  
        librt.so.1 => /usr/lib/librt.so.1 (0x00007f155ddd1000)  
        libicui18n.so.61 => /usr/lib/libicui18n.so.61 (0x00007f155d926000)  
        libgomp.so.1 => /usr/lib/libgomp.so.1 (0x00007f155d6f8000)  
        libicudata.so.61 => /usr/lib/libicudata.so.61 (0x00007f155bb53000)  
        libncursesw.so.6 => /usr/lib/libncursesw.so.6 (0x00007f155b8e6000)  
        libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00007f155b698000)  
        libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00007f155b3af000)  
        libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00007f155b17c000)  
        libcom_err.so.2 => /usr/lib/libcom_err.so.2 (0x00007f155af78000)  
        libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00007f155ad6b000)  
        libkeyutils.so.1 => /usr/lib/libkeyutils.so.1 (0x00007f155ab67000)  
        libresolv.so.2 => /usr/lib/libresolv.so.2 (0x00007f155a950000)

Still not sure why this happened since other packages that depend on gccfortran are able to find and use the libgfortran.so.5 on the system.

@chengarthur
Copy link

same problem when you installing igraph in Ubuntu 16
I solved this problem by update source and used following
sudo apt-get install gcc-4.8-base libgfortran4

@OscarSouth
Copy link
Author

@cls3415 $HOME/.R/Makevars

@OscarSouth
Copy link
Author

@danielee0707 I tried that out myself (rebuilt some packages today including igraph) and it also worked for me

@HenrikEckermann
Copy link

HenrikEckermann commented Aug 25, 2018

I have the same issue. But editing the Makevars did not work for me.

Do I maybe leave out the "#" before each line?
I lost 2hs now and it annoys the hell out of me. I don't find the files in anaconda3 mentioned above so far...

If you have other idea @OscarSouth , please let me know!

Thanks

Edit: Never mind, I set up a new instance and used the rutter R 3.5 package list and it worked.

@OscarSouth
Copy link
Author

My preferred solution in the end is that suggested by @danielee0707

@cramjaco
Copy link

@danielee0707 's strategy worked for me. I found there were about four versions of libgfortran.so.4.0.0. Navigating to my anacondas directory and running
`find . -name "libgfortran.so.4.0.0" -execdir mv {} {}_off ';'

then

library(devtools)
install_github("igraph/rigraph")

`
seemed to get things working.

Some things that didn't work, in my case:

I had removed the Makevars file suggested by @OscarSouth
when I performed this installation. The makevars file by itself did not seem to help me.

@chengarthur 's suggestion of running

sudo apt-get install gcc-4.8-base libgfortran4

did not seem to help

@WilliamBarela
Copy link

I just had the same problem installing igraph in Ubuntu 16.04 on R 3.5.2. I can confirm that this issue is due to the package installer trying to use the shared object library for libgfortran in Anaconda3 when compiling the igraph package.

A very quick and dirty work around for this is to temporarily break your Anaconda installation by moving it to a .bak folder, install igraph in R, and then move Anaconda back to its original directory name.

$ whereis anaconda
$ anaconda: /opt/anaconda3/bin/anaconda
$ # adjust the next line based on the output from the whereis command
$ # sudo mv /opt/anaconda3/ /opt/anaconda3.bak
$ R
> install.packages("igraph")
> q()
> n
$ # again, adjust the next line based on the output from the whereis command
$ # sudo mv /opt/anaconda3.bak/ /opt/anaconda3

Now if you load igraph with library(igraph) it should work and Anaconda will too.

NB: You do not need sudo in the above command if you have Anaconda installed in your home directory.

@vtraag
Copy link
Member

vtraag commented Oct 21, 2021

By the way, are there any updates on when the next release of igraph will be available on CRAN? I think this would also avoid people needing to install from GitHub to use the new features.

igraph 1.2.7 was just released a few days ago. However, there are no binary packages for Linux served by CRAN, so people still need to compile it.

Generally I’d recommend avoiding using R in conda environments where possible as it may still run another R version of it is in your PATH.

Could you elaborate on this? I would assume that conda sets the paths correctly when activating an environment. Python also has the same problem; on most platforms there is also a system Python available. With Python I never experienced path problems between conda and system Python though. Does this work differently for R somehow?

@gaborcsardi
Copy link
Contributor

gaborcsardi commented Oct 21, 2021

Some comments.

I actually did not manage to reproduce this. I used Ubuntu 18.04 with stock R, downloaded Anaconda with Python 3.8, activated it, and igraph installed just fine.

This said, it is not hard to see how things can go wrong. conda comes with all of its dependencies included, probably because they don't want to rely on the system and want you to use conda to manage all the software it uses.

Which is fine, except that when you want to compile or use non-conda software, e.g. R from Ubuntu, you need to deactivate conda, otherwise your non-conda software will depend on a mixture of the conda libraries and the system libraries. This might work depending on what versions of what libraries are installed in conda and the system, but often it won't. It will typically fail if conde is much older or much newer than the system you are running it on.

E.g. when you compile igraph with an active conda you'll see things like

checking for sys/file.h... yes
checking for struct sockaddr.sa_len... no
checking for xml2-config... /root/anaconda3/bin/xml2-config
checking for xmlSAXUserParseFile in -lxml2... yes
checking for libxml/parser.h... yes
checking for __gmpz_add in -lgmp... yes
checking for gmp.h... yes
checking how to run the C preprocessor... /root/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cpp

so igraph will use libxml2 from conda. This will work if the system libraries are compatible with that, otherwise it won't.

Moreover conda's xml-config will add a bunch of compiler flags, so igraph will be linked as

...
... rinterface_extra.o lazyeval.o -L/root/anaconda3/lib -lxml2 -L/root/anaconda3/lib -lz 
-L/root/anaconda3/lib -llzma -lpthread -L/root/anaconda3/lib -L/root/anaconda3/lib -licui18n 
-licuuc -licudata -lm -ldl -lgmp -llapack -lblas -lgfortran -lm -lquadmath -lgfortran 
-lm -lquadmath -L/usr/lib/R/lib -lR

which basically means that the libraries in conda are preferred over the system libraries. Not good.

In summary, R relies on the system libraries, and when conda is active it will override a subset of the system libraries. The resulting mixture of libraries might not work together properly. This is not specific to R, an active conda might break any non-conda compilation or usage this way. Again, the solution is to deactivate conda.

I also don't see what igraph can do about this. Maybe we can give a loud warning when conda is active but you are using non-conda R, and tell people to deactivate conda? I am not sure how to detect this, but it is probably possible.

r-igraph is already on Conda, AFAICT most popular R packages are.

@gjhuizing

This comment has been minimized.

@szhorvat
Copy link
Member

I actually did not manage to reproduce this. I used Ubuntu 18.04 with stock R, downloaded Anaconda with Python 3.8, activated it, and igraph installed just fine.

This illustrates well the unpredictability of the situation: Whether the conflicts happen will also depend on what is installed in the currently active Conda environment (which constantly change as the users adds/removes/updated conda packages).


To reiterate: Always fully deactivate all conda environments before compiling igraph, or any other software. This is the right solution. If your igraph depends on libraries within your Anaconda installation then you're on thin ice for the reasons detailed in Gábor's comment.


First I ran locate libmkl_rt.so.1. Then I added the path to ldconfig using sudo ldconfig /export/home1/users/csb/huizing/anaconda3/lib/.

This is dangerous. Please just do not do that.

@gaborcsardi
Copy link
Contributor

First I ran locate libmkl_rt.so.1. Then I added the path to ldconfig using sudo ldconfig /export/home1/users/csb/huizing/anaconda3/lib/.

This is dangerous. Please just do not do that.

To elaborate, this will make all your system software (including R) potentially depend on the conda libs, even when you deactivate conda. So it is better not to do that.

@gjhuizing
Copy link

First I ran locate libmkl_rt.so.1. Then I added the path to ldconfig using sudo ldconfig /export/home1/users/csb/huizing/anaconda3/lib/.

This is dangerous. Please just do not do that.

To elaborate, this will make all your system software (including R) potentially depend on the conda libs, even when you deactivate conda. So it is better not to do that.

Okay thanks I understand now! I hid my own reply so that people won't be tempted to copy paste :)

@vtraag
Copy link
Member

vtraag commented Oct 25, 2021

r-igraph is already on Conda,

Sorry, I was not aware it was already available.

@szhorvat
Copy link
Member

r-igraph is already on Conda,

Sorry, I was not aware it was already available.

I was only able to find this, which is an older version: https://anaconda.org/r/r-igraph

However, as far as I understood, no one in this thread was asking to use R/igraph within the Anaconda ecosystem. People tried to compile igraph either with the official R distribution, or their Linux distro's R, not Anaconda's R. It just happened to be the case that the most common cause of failure was interference from an active conda environment. I think the best solution here might be less conda, not more conda (i.e. just deactivate conda when compiling igraph).

@gaborcsardi
Copy link
Contributor

I was only able to find this, which is an older version: anaconda.org/r/r-igraph

I don't think it is old. Older than the release 10 days ago, sure, but otherwise there hasn't been anything new in the R package: https://github.com/igraph/rigraph/blob/dev/inst/NEWS.md

@ntamas ntamas closed this as completed Jan 18, 2022
@gustavomirapalheta
Copy link

Installing igraph in RStudio with no active Conda environment solved the problem for me. I think this is the easiest and safest solution.

@TheRealDrDre
Copy link

Pulled at this string and finally managed to get it to install by creating a .R/Makevars file with the following lines:

#F77 = /usr/bin/gfortran
#FC = $F77
#FLIBS = -L/usr/bin/gfortran

then running

library(devtools)
install_github("igraph/rigraph")

Cheers for pointing me in the right direction!

Just want to add that this solution work worked for me too, on PopOS! 20.04.

@szhorvat
Copy link
Member

@TheRealDrDre What does which gfortran say on your system, when run from a terminal?

@TheRealDrDre
Copy link

@TheRealDrDre What does which gfortran say on your system, when run from a terminal?

andrea@pop-os:~/.R$ which gfortran /usr/bin/gfortran

@szhorvat
Copy link
Member

szhorvat commented Sep 15, 2022

@TheRealDrDre Do you use Anaconda? Did you have any conda environment active when you tried to install igraph?

Also, can you post the exact error message that you got when you tried to compile igraph?

We are looking to write a troubleshooting document for the most common installation issues. It would help to better understand what exactly is happening. My working hypothesis is that basically all complaints about a missing libgfortran.so.4 are due to an active conda environment, but it's not clear if this environment needs to contain a gfortran installation or merely a libgfortran library.

@TheRealDrDre
Copy link

TheRealDrDre commented Sep 15, 2022

Hi @szhorvat . I do have anaconda. I had dactivated the conda environment before and tried to install igraph unsuccessfully. With the conda environment deactivated and the .R/Makevars in place, igraph compiled right away. (PS: conda is back to active now)

@Ge526874
Copy link

I just had the same problem installing igraph in Ubuntu 16.04 on R 3.5.2. I can confirm that this issue is due to the package installer trying to use the shared object library for libgfortran in Anaconda3 when compiling the igraph package.

A very quick and dirty work around for this is to temporarily break your Anaconda installation by moving it to a .bak folder, install igraph in R, and then move Anaconda back to its original directory name.

$ whereis anaconda
$ anaconda: /opt/anaconda3/bin/anaconda
$ # adjust the next line based on the output from the whereis command
$ # sudo mv /opt/anaconda3/ /opt/anaconda3.bak
$ R
> install.packages("igraph")
> q()
> n
$ # again, adjust the next line based on the output from the whereis command
$ # sudo mv /opt/anaconda3.bak/ /opt/anaconda3

Now if you load igraph with library(igraph) it should work and Anaconda will too.

NB: You do not need sudo in the above command if you have Anaconda installed in your home directory.

Thanks! It works

@Jidgdoi
Copy link

Jidgdoi commented Oct 26, 2022

Both errors linked to "libgfortran.so.4.0.0" and "libmkl_rt.so.1" happend to me.

Solutions mentionned to rename all those files found in miniconda worked for me.

for i in $(find miniconda3/* -name "*libgfortran.so.4*"); do mv ${i} ${i}.backup; done for i in $(find miniconda3/* -name "*libmkl_rt.so*"); do mv ${i} ${i}.backup; done

And then install igraph:
install.packages("igraph")

@szhorvat
Copy link
Member

Solutions mentionned to rename all those files found in miniconda worked for me.

Don't do that. Instead, always deactivate any conda environments before compiling igraph or any other software. Conda has the potential to create conflicts, as you just experienced. Troubleshooting information is here: https://github.com/igraph/rigraph/wiki/Installation-Troubleshooting

@Jidgdoi
Copy link

Jidgdoi commented Oct 26, 2022

Solutions mentionned to rename all those files found in miniconda worked for me.

Don't do that. Instead, always deactivate any conda environments before compiling igraph or any other software. Conda has the potential to create conflicts, as you just experienced. Troubleshooting information is here: https://github.com/igraph/rigraph/wiki/Installation-Troubleshooting

Yeah it would be the good thing to do if only i add a conda environment activate, but this is not the case :-/ ... So how is it possible to prevent R from checking for librairies in conda folders ?

@szhorvat
Copy link
Member

Are you certain that you do not have any environment active, not even the base environment? What does echo $CONDA_DEFAULT_ENV output?

Also check your PATH environment variable. It should not contain any directories from your Anaconda installation except condabin, which contains the conda command alone.

@Jidgdoi
Copy link

Jidgdoi commented Oct 26, 2022

Are you certain that you do not have any environment active, not even the base environment? What does echo $CONDA_DEFAULT_ENV output?

Also check your PATH environment variable. It should not contain any directories from your Anaconda installation except condabin, which contains the conda command alone.

Yes i'm sure, echo $CONDA_DEFAULT_ENV outputs nothing, and only my miniconda3/bin is present in my $PATH.

But anyway, I accord you that the solution isn't pretty, but at least it works ! Can't ask more with this deadly R langage.

@szhorvat
Copy link
Member

and only my miniconda3/bin is present in my $PATH.

This is very likely the source of the problem. That directory contains all executables installed into the base environment. Inly miniconda3/condabin should be in the path, not miniconda3/bin. I believe older conda versions added bin, which is what may have happened on your system.

You may want to edit your profile and delete the line that adds miniconda3/bin to the PATH. Then use conda init to get conda's updated shell integration. See conda init --help for how to use it.

Can't ask more with this deadly R langage.

This is not really related to R. Expect trouble when building/installing any software that uses Fortran or BLAS.

@igorkf
Copy link

igorkf commented Feb 25, 2023

In my case it was resolved doing

sudo apt-get install libgfortran4

@szhorvat
Copy link
Member

szhorvat commented Feb 25, 2023

@igorkf This is not the correct solution, as you are not addressing the true cause of the problem, and you are risking further issues. Please see the troubleshooting document:

https://github.com/igraph/rigraph/wiki/Installation-Troubleshooting

@Merlyn1009
Copy link

Yes, then you built from a source package, so I am not sure why it was broken. I would try to just re-install it.

You can use the --no-clean-on-error option, that keeps the installed package, even if you can't load it:

install.packages("igraph", INSTALL_opts = "--no-clean-on-error")

and then try to load it:

library(igraph)

If loading fails, check which libs the igraph shared lib links to:

ldd /home/oscarsouth/R/x86_64-pc-linux-gnu-library/3.5/igraph/libs/igraph.so

it works!!!!!!!!Thank you

@airuchen
Copy link

@TheRealDrDre What does which gfortran say on your system, when run from a terminal?

Check which gfortran is quite helpful. It turned out that the path showed /home/linuxbrew/.linuxbrew/bin/gfortran. After the gfortran under linuxbrew was deleted, it automatically linked to /usr/bin/gfortran. Afterward, install.packages("igraph") worked

@jake-bioinfo
Copy link

I did not try in the base environment.

I did not say to try it in the base environment. I suggested to deactivate conda completely. With a proper conda setup, this is achievable through conda deactivate.

I wonder if it is fair to call it a conda issue

It is very difficult to create a build system that will "just work" in all conditions and all environments, and will find dependencies, as well as dependencies of dependencies, and so on. I would call it impossible, given that it is necessary to rely on each user's particular settings, which will sometimes be inconsistent. I have seen conda environment interfere with the compilation of other software as well.

You should follow these guidelines:

  • Are you using Anaconda's own R? Then have the appropriate conda environment active.
  • Are you using some other R? Then fully deactivate conda before compilation.
  • Are compiling a package unrelated to R? Again, fully deactivate conda.

This worked for me and is a much better suggestion than what the igraph installation troubleshooter offers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests