Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R 3.2, GCC, and homebrew

I recently needed to install R 3.2 to get a package from Bioconductor working, but after I installed, I get the following error:

[16:16:11 20] $ r
dyld: Library not loaded: /usr/local/lib/gcc/4.9/libgfortran.3.dylib
  Referenced from: /usr/local/Cellar/r/3.2.0/R.framework/Versions/3.2/Resources/lib/libR.dylib
  Reason: image not found
Trace/BPT trap: 5

Sure enough, brew was set to use gcc 5, so I told brew to use the 4.9 version

brew switch gcc 4.9

which got R running, but then R would fail in the middle of a package install (specifically when I ran biocLite('DESeq2').

Since then, I have tried a number of things, including trying to install gcc 4.8 (but I can't seem to get R to use it, even via ~/.R/Makevars). Even if 4.9 is not installed, R insists on calling the path shown above.

The windows version of R seems to say 4.9 does not work with 3.2:

R-devel temporarily used a new toolchain based on 4.9.2 gcc, put together by Duncan Murdoch using build scripts written by a contractor. However, there were too many incompatibilities with existing code, and this toolchain will not be used for R 3.2.0. See notes for details on building and testing the new toolchain.

Any help would be greatly appreciated!

Edit: I tried installing from source, as suggested by @lmw., but it fails:

[11:27:55 2] $ brew install r --build-from-source
==> Installing r from homebrew/homebrew-science
==> Installing r dependency: gcc
==> Downloading http://ftpmirror.gnu.org/gcc/gcc-5.1.0/gcc-5.1.0.tar.bz2
######################################################################## 100.0%
curl: (28) Resolving timed out after 5542 milliseconds
Trying a mirror...
==> Downloading https://ftp.gnu.org/gnu/gcc/gcc-5.1.0/gcc-5.1.0.tar.bz2
######################################################################## 100.0%
==> Patching
patching file gcc/jit/Make-lang.in
==> ../configure --build=x86_64-apple-darwin14.3.0 --prefix=/usr/local/Cellar/gcc/5.1.0 --libdir=/usr/local/Cellar/gc
==> make bootstrap
==> make install
==> Caveats
GCC has been built with multilib support. Notably, OpenMP may not work:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60670
If you need OpenMP support you may want to
  brew reinstall gcc --without-multilib
==> Summary
🍺  /usr/local/Cellar/gcc/5.1.0: 1351 files, 248M, built in 32.5 minutes
==> Installing r
==> Using Homebrew-provided fortran compiler.
This may be changed by setting the FC environment variable.
==> Downloading http://cran.rstudio.com/src/base/R-3/R-3.2.0.tar.gz
######################################################################## 100.0%
==> Patching
patching file src/modules/lapack/vecLibg95c.c
==> ./configure --prefix=/usr/local/Cellar/r/3.2.0_1 --with-libintl-prefix=/usr/local/opt/gettext --enable-memory-pro
==> make
** installing vignettes
** testing if installed package can be loaded
* DONE (survival)
make[1]: *** [recommended-packages] Error 2
make: *** [stamp-recommended] Error 2

READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/homebrew):
  https://github.com/homebrew/homebrew-science/issues

Edit 2: Just for the fun of it, I tried installing r without the --build-from-source option, and it worked. See my solution below. (I think building from source may have fixed the issue with the gcc 5 upgrade, which got things working. I am not going to try it (things are finally working again...why screw with it?), but I wonder if I could remove the variables I set in ~/.R/Makevars (again, see solution below).

like image 995
muppetjones Avatar asked May 21 '15 21:05

muppetjones


2 Answers

Rebuilding R from source fixes the same problem for me.

brew reinstall r --build-from-source

like image 163
LmW. Avatar answered Nov 03 '22 14:11

LmW.


This was resolved by this commit, with new bottles for R. Make sure you brew update and brew upgrade r.

like image 42
ianml Avatar answered Nov 03 '22 14:11

ianml