R 3.2, GCC, and homebrew - r

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).

Rebuilding R from source fixes the same problem for me.
brew reinstall r --build-from-source

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

This is not a complete fix (it uses an older gcc version), but it get's me running again:
brew tap homebrew/homebrew-versions
brew install gcc48
brew install r
NOTE: I ran brew install r --build-from-source (reinstall did not work), which rebuilt something, but not r (it failed). It may be partially responsible for this working. Please let me know if it is! I'd like to give #lmw credit if his answer is the reason this worked.
Edit ~/.R/Makevars and add the following lines (edit paths as necessary):
CC=/usr/local/Cellar/gcc48/4.8.4/bin/gcc-4.8
CXX=/usr/local/Cellar/gcc48/4.8.4/bin/g++-4.8
CFLAGS=-std=c99
Run r.
(If you're trying to install bioconductor)
source("http://bioconductor.org/biocLite.R")
biocLite()

Related

Initial Rattle issues (Os) "Error: -with-x11" & "Error: gtk+ 2.24.32 did not build"

I have been trying to install Rattle on my Os into my R using this instructions:
https://zhiyzuo.github.io/installation-rattle/
I get to Line 7 and input
~$ brew install --with-x11 cairo
and then get
Updating Homebrew...
Usage: brew install [options] formula|cask
Install a formula or cask. Additional options specific to a formula may be
appended to the command.
Unless HOMEBREW_NO_INSTALL_CLEANUP is set, brew cleanup will then be run for
the installed formulae or, every 30 days, for all formulae.
...
**Error: invalid option: --with-x11**'''
Ive tried to continue on installing Cairo without the "--with-x11" (as been suggested they no longer support that).
So I did just "brew install cairo" that worked.
I go to line 9 Now we can install gtk+ by:
~$ brew install --build-from-source --verbose gtk+
And I get:
**Error: gtk+ 2.24.32 did not build
Logs:
/Library/Logs/Homebrew/gtk+/00.options.out
/Library/Logs/Homebrew/gtk+/01.configure.cc
/Library/Logs/Homebrew/gtk+/config.log
/Library/Logs/Homebrew/gtk+/01.configure
READ THIS: https://docs.brew.sh/Troubleshooting'''
If this helps in the last part I see in the terminal things saying:
==> ./configure --disable-dependency-tracking --disable-silent-rules - -prefix=/usr/local/Cellar/gtk+/2.24.32_3 --disable-glibtest --enable-introspection=yes --with-gdktarget=x11 --enable-x11-backend
configure: WARNING: unrecognized options: --enable-x11-backend
and
configure: error: Package requirements (cairo-xlib >= 1.6) were not met:
No package 'cairo-xlib' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables CAIRO_BACKEND_CFLAGS
and CAIRO_BACKEND_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
Anyone have any suggestions for this ?
Thanks.

Solve ld linker issues for building R source

While trying to install R from source, I ran into linker issues, in particular: undefined reference to 'u_getVersion_58
I found limited information on this error (eg, this post on the RStudio forum).
Despite running apt-get build-dep, these issues persisted.
It is apparent from these comments by Dirk Eddenbuettel that it relates to libicu versions. I have libicu version 60, while R 3.6.0 and similar recent versions seem to require version 58.
We can install a previous version of libicu from source as follows:
wget http://download.icu-project.org/files/icu4c/58.2/icu4c-58_2-src.tgz
tar -xf icu4c-58_2-src.tgz
cd icu
make
make install
However, make is likely to run into a compilation error due to missing xlocale.h. As indicated on this github post, this can be solved by running ln -s /usr/include/locale.h /usr/include/xlocale.h, as xlocale.h is just a subset of locale.h which was removed from glibc recently. After this, make and make install should succeed for icu version 58, and following that, for R.

On CentOS Linux 7.4, cannot install the R package "httpuv"

I am currently using CentOS Linux 7.4.1708 (Core). I have tried to install the package httpuv in R through various methods to no avail. It always ends with the error:
CC src/unix/libuv_la-procfs-exepath.lo
CC src/unix/libuv_la-proctitle.lo
CC src/unix/libuv_la-sysinfo-loadavg.lo
CC src/unix/libuv_la-sysinfo-memory.lo
CCLD libuv.la
libtool: error: require no space between '-L' and '-L/n/helmod/apps/centos7/Core/pcre/8.37-fasrc02/lib'
make[1]: *** [libuv.la] Error 1
make[1]: Leaving directory `/tmp/Rtmp5Dj7hL/R.INSTALL5c046d96dc92/httpuv/src/libuv'
make: *** [libuv/.libs/libuv.a] Error 2
ERROR: compilation failed for package ‘httpuv’
Does anyone have any thought as to what is going on here? Thanks.
The previous answer is partially correct in that it identifies libuv as the missing dependency.
In CentOS 7 you can add this with yum install libuv-devel, then attempt to install the package again with install.packages("httpuv") and provided that was your only issue, it should compile correctly.
The error says that there is a library error in libuv.la.
The cc and CCLD commands show that this is a compilation error - very likely from gcc thrown when trying to compile libuv.la.
In ubuntu linux, I would look in such cases:
$ apt search httpuv
# which gives:
# r-cran-httpuv
R packages with mostly need other system dependencies (libraries outside of R etc) mostly have a package in the apt repository.
Then you do simply:
$ sudo apt install r-cran-httpuv
And then every dependency problems are resolved (though it might be that R asks you to update/upgrade your package after the installation - which sometimes works but sometimes not).
I was looking if CentOS can use apt:
https://everyday-tech.com/apt-get-on-centos/
Another possibility for you would be to use conda which is great to solve such dependency problems. People have then similar to apt prepared for you conda-packages which provide all package dependencies.
$ conda install -c conda-forge r-httpuv
If you don't know conda, I highly recommend you this tutorial:
https://www.youtube.com/watch?v=YJC6ldI3hWk (from Corey Schafer who gives great - mainly Python - tutorials).

Errors building R-packages for conda

I am having a tough time installing R-packages that are not available in the Anaconda repositories. My attempts so far can be found here How to install R-packages not in the conda repositories?.
Currently, I am trying to build the R-package rafalib for conda by following the instructions from this article under the heading Building a conda R package.
The first part works fine.
conda skeleton cran rafalib
Out:
Tip: install CacheControl to cache the CRAN metadata
Fetching metadata from http://cran.r-project.org/
Writing recipe for rafalib
Done
The build command runs into errors
conda build r-rafalib
Out:
Removing old build environment
Removing old work directory
BUILD START: r-rafalib-1.0.0-r3.2.2_0
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ......
Solving package specifications: .
Error: Packages missing in current linux-64 channels:
- r 3.2.2*
- r-rcolorbrewer
I have r 3.2.2-64bit installed via conda and it runs without problems. I also already have r-colorbrewer installed via conda and I can use that package without issues in R. Why am I getting these errors when trying to build a conda package?
I am on Linux (Antergos, an Arch derivative) with kernel 4.4.5-1-ARCH.
UPDATE 2015/04/19
Thanks to this answer, I found out that I could include the dependencies by building them separately in the same directory as the package I want to install. That didn't work for me, but I also read that I can include a channel in the build command with -c, just as when installing. So now I do:
conda build -c r r-rafalib
This gets passed all the dependency problems, but after fetching, extracting and linking packages, it fails. Here is the end of the error message.
Removing old work directory
Source cache directory is: /home/joel/anaconda2/conda-bld/src_cache
Downloading source to cache: rafalib_1.0.0.tar.gz
Downloading http://cran.r-project.org/src/contrib/rafalib_1.0.0.tar.gz
rafalib_1.0.0. 100% |#######################| Time: 0:00:00 4.87 MB/s
Success
Extracting download
Package: r-rafalib-1.0.0-r3.2.2_0
source tree in: /home/joel/anaconda2/conda-bld/work/rafalib
+ mv DESCRIPTION DESCRIPTION.old
+ grep -v '^Priority: ' DESCRIPTION.old
+ /home/joel/anaconda2/envs/_build/bin/R CMD INSTALL --build .
sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook
Command failed: /bin/bash -x -e /home/joel/drafts/r-rafalib/build.sh
The error sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook is the same as I encounter when using install.packages() as reported here.
There is some related discussion in this thread. I have tried to get around this error by installing different versions of ncurses, including this patched version, and I have tried to link the readline libraries, as suggested here, but I keep running into the same error. I'm quite lost at this point and any help to solve this would be greatly appreciated.
Although I started out with a different problem, the final solution turned out to be the same as I posted elsewhere How to install R-packages not in the conda repositories?. I am adding it here for completeness.
In the end, I got around the rl_event_hookproblems by following the approach recommended here and symlinking anaconda's libreadline to the system one:
mv ~/anaconda3/lib/libreadline.s.6.2 ~/anaconda3/lib/libreadline.s.6.2.bak
ln -s /usr/lib/libreadline.so.6.3 ~/anaconda3/lib/libreadline.s.6.2
I am still having troubles installing some dependency heavy R-packages due to failure to load shared objects when using install.packages() from withing R. However, simpler packages work fine and I can get most of the dependency heavy packages from anacondas R-repositories.

R cmd check not locating texi2pdf on mac after R 3.1.3 upgrade

Does anyone have a link to clear instructions on how to install and configure the necessary latex packages to build R packages on a mac?
I have some scripts for building and checking R packages on a mac server. They seemed to work fine, but after upgrading to R 3.1.3, many of the packages started failing with
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'networkVignette.tex' failed.
Messages:
sh: /usr/local/bin/texi2dvi: No such file or directory
Calls: <Anonymous> -> texi2pdf -> texi2dvi
Execution halted
I found a thread which seemed to suggest I need a more recent version texinfo (5.2) than what is installed by default. And apparently I've I've got the wrong version installed in the wrong location?
which texi2pdf
/sw/bin/texi2pdf
texi2pdf --version
texi2pdf (GNU Texinfo 5.1) 5234
(same version is reported when running system('texi2pdf --version') in R )
This thread gives a link to a texinfo 5.2 source collection:
http://r.789695.n4.nabble.com/R-CMD-build-looking-for-texi2dvi-in-the-wrong-place-R-devel-td4701706.html
But I'm not familiar with installing executable from a tar.gz file on a mac. The R mac help pages I found suggest installing MacTex, which I tried but that didn't seem to help.
** Update: ** additional discussion of related problems on R-SIG-mac mailing list:
https://groups.google.com/forum/#!topic/r-sig-mac/xjyuFdl5Ezk
Update:
Here is where I'm currently at:
I removed my /sw directory to uninstall fink and all of its packages (couldn't figure out how to upgrade it)
installed homebrew
brew install texinfo installs version 5.2 the package,
but generates the message This formula is keg-only, which means it was not symlinked into /usr/local and actually installs in in /usr/local/Cellar/texinfo/5.2/bin which means it is not on the path and R won't find it.
manually symlink each of the texi2pdf, texi2dvi , etc as vincent suggests (this is because R has the /usr/local/bin location as default in the tools::texi2dvi function?
edited the /etc/paths file on the system to add /usr/local/bin so that finds the brew installed 5.2 version before it finds it before the osx system supplied version 4.6 version. This may not be necessary because R has it hardcoded?
All of this gets rid of the "can't find texi* errors", and gives me a bunch of latex errors (which I don't see on unix and windows builds) so I'm still kind of stuck.
This seems very hackish, so there must be a cleaner way? But it sounds like stuff with tex and mac is very sketchy at the moment? https://tex.stackexchange.com/questions/208181/why-did-my-tex-related-gui-program-stop-working-in-mac-os-x-yosemite
This worked for me on Mavericks and on Yosemite:
ln -s /usr/bin/texi2dvi /usr/local/bin/texi2dvi
ln -s /usr/bin/texi2pdf /usr/local/bin/texi2pdf
On my Lion system both the command which texi2pdf at a Terminal/bash prompt and from a R.app GUI prompt tell me that I have that program in:
system("which texi2pdf")
#/opt/local/bin/texi2pdf
That is a location typical for MacPorts installation. I think the /usr/local/bin/ is what the binary R version "expects". I'm not really that UNIX savvy, but I think the you can modify the PATH environment variable so that R will be able to find your installation. (Whether it will be compatible I cannot say since so much detail is missing from your question.) My Tex installation is MacTex, which I got from https://www.tug.org/mactex/. I admit to having a cobbled-together system:
system("echo $PATH")
# /opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin
That gets set at the beginning of an R session because this is the first line in my .Rprofile-(invisible)file:
Sys.setenv(PATH="/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin")
I think /sw/bin/ installations signify a fink install, which I have had very little success with. Simon Urbanek suggests not using any package installers, but then leaves the rest of us UNIX weenies very little in the way of worked examples of how to install that various external packages that underpin the many interesting and oh-so-useful R packages. So I feel your pain, but I'm not running for President.
So I suppose you could try this at your R console before again attempting one of the earlier unsuccessful installs:
Sys.setenv(PATH=paste( Sys.getenv()$PATH, # should be the character string of the $PATH
"/sw/bin/", sep=":")
)
Wish I could offer guarantees, but if it breaks the only guarantee is that you get to keep all the pieces.
I ran into a similar error message using Mavericks 10.9.5 (factory configured) and R 3.1.
It turns out that I didn't have pdfLaTex. I went to this page: http://tug.org/mactex/ and downloaded the MacTex installation package. It's big (>2GB) but after I installed it, my R package build problems went away.
Hope this might be helpful to anyone else who runs into this error message.

Resources