まずインストール(失敗)
いつものように readline と openssl を付けてインストール
$ env CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline` --with-openssl-dir=`brew --prefix openssl`" rbenv install 1.8.7-p375 Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Checking out http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7... Installing ruby-1.8.7-p375... BUILD FAILED Inspect or clean up the working tree at /var/folders/r8/t51gts3s5kb5b5qvskswx22c0000gn/T/ruby-build.20140925131826.33061 Results logged to /var/folders/r8/t51gts3s5kb5b5qvskswx22c0000gn/T/ruby-build.20140925131826.33061.log Last 10 log lines: Checked out revision 44351. /var/folders/r8/t51gts3s5kb5b5qvskswx22c0000gn/T/ruby-build.20140925131826.33061/ruby-1.8.7-p375 /var/folders/r8/t51gts3s5kb5b5qvskswx22c0000gn/T/ruby-build.20140925131826.33061 /Volumes/share/prog/Ruby/enewskeeper/cnnstudentnews configure: WARNING: unrecognized options: --with-readline-dir, --with-openssl-dir, --with-readline-dir checking build system type... i686-apple-darwin13.4.0 checking host system type... i686-apple-darwin13.4.0 checking target system type... i686-apple-darwin13.4.0 checking whether the C compiler works... no configure: error: in `/var/folders/r8/t51gts3s5kb5b5qvskswx22c0000gn/T/ruby-build.20140925131826.33061/ruby-1.8.7-p375': configure: error: C compiler cannot create executables See `config.log' for more details BUILD FAILED Inspect or clean up the working tree at /var/folders/r8/t51gts3s5kb5b5qvskswx22c0000gn/T/ruby-build.20140925131826.33061 Results logged to /var/folders/r8/t51gts3s5kb5b5qvskswx22c0000gn/T/ruby-build.20140925131826.33061.log Last 10 log lines: /var/folders/r8/t51gts3s5kb5b5qvskswx22c0000gn/T/ruby-build.20140925131826.33061/ruby-1.8.7-p375 /var/folders/r8/t51gts3s5kb5b5qvskswx22c0000gn/T/ruby-build.20140925131826.33061 /Volumes/share/prog/Ruby/enewskeeper/cnnstudentnews configure: WARNING: unrecognized options: --with-readline-dir, --with-openssl-dir, --with-readline-dir checking build system type... i686-apple-darwin13.4.0 checking host system type... i686-apple-darwin13.4.0 checking target system type... i686-apple-darwin13.4.0 checking whether the C compiler works... no configure: error: in `/var/folders/r8/t51gts3s5kb5b5qvskswx22c0000gn/T/ruby-build.20140925131826.33061/ruby-1.8.7-p375': configure: error: C compiler cannot create executables See `config.log' for more details make: *** No targets specified and no makefile found. Stop.
だめでした。 C コンパイラの問題ですね。
先人の教え
- funkaster commented on 6 May
I had the same problem. Installing gcc-4.7 with homebrew (brew install gcc47) and then CC=gcc-4.7 rbenv install 1.8.7-p375 fixed this for me.
- masasakano commented on 26 May
I met the same problem, too. The reply from @funkaster was most helpful (thank you!). The exact command stated did not work, so I tweaked to: brew install homebrew/versions/gcc47
The latter worked fine: CC=gcc-4.7 rbenv install 1.8.7-p375
Can't install ruby 1.8.7 on Mavericks · Issue #571 · sstephenson/rbenv
gcc-4.7インストール
$ brew install gcc47 Error: No available formula for gcc47 Searching taps... homebrew/versions/gcc47 $ brew search gcc gcc homebrew/versions/gcc43 homebrew/versions/gcc48 homebrew/versions/gcc44 homebrew/versions/gcc49 homebrew/versions/gcc45 homebrew/versions/llvm-gcc28 homebrew/versions/gcc46 homebrew/dupes/apple-gcc42 homebrew/versions/gcc47 $ brew info gcc gcc: stable 4.9.1 (bottled) http://gcc.gnu.org /usr/local/Cellar/gcc/4.8.3_1 (1046 files, 178M) Poured from bottle /usr/local/Cellar/gcc/4.9.1 (1152 files, 203M) * Poured from bottle From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/gcc.rb ==> Dependencies Required: gmp ✔, libmpc ✔, mpfr ✔, cloog ✔, isl ✔ ==> Options --with-all-languages Enable all compilers and languages, except Ada --with-java Build the gcj compiler --with-nls Build with native language support (localization) --without-fortran Build without the gfortran compiler --without-multilib Build without multilib support ==> 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
いま gcc-4.9.1 が入ってるんですね。でも 1.8.7 には gcc-4.7 が要るようなので入れていきます。
$ brew install homebrew/versions/gcc47 Cloning into '/usr/local/Library/Taps/homebrew/homebrew-versions'... remote: Counting objects: 2379, done. remote: Total 2379 (delta 0), reused 0 (delta 0) Receiving objects: 100% (2379/2379), 772.19 KiB | 81.00 KiB/s, done. Resolving deltas: 100% (1357/1357), done. Checking connectivity... done. Tapped 160 formulae ==> Installing dependencies for gcc47: gmp4, mpfr2, libmpc08, ppl011, clo ==> Installing gcc47 dependency: gmp4 ==> Downloading ftp://ftp.gmplib.org/pub/gmp-4.3.2/gmp-4.3.2.tar.bz2 ######################################################################## 100.0% ==> Patching patching file gmp-h.in Hunk #1 succeeded at 46 with fuzz 2. ==> ./configure --prefix=/usr/local/Cellar/gmp4/4.3.2 --enable-cxx --build=x86_6 ==> make ==> make install ==> make check ==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local. Conflicts with gmp in main repository. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/gmp4/lib CPPFLAGS: -I/usr/local/opt/gmp4/include ==> Summary 🍺 /usr/local/Cellar/gmp4/4.3.2: 15 files, 2.5M, built in 6.4 minutes ==> Installing gcc47 dependency: mpfr2 ==> Downloading http://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.bz2 ######################################################################## 100.0% ==> ./configure --prefix=/usr/local/Cellar/mpfr2/2.4.2 --with-gmp=/usr/local/opt ==> make ==> make check ==> make install ==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local. Conflicts with mpfr in main repository. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/mpfr2/lib CPPFLAGS: -I/usr/local/opt/mpfr2/include ==> Summary 🍺 /usr/local/Cellar/mpfr2/2.4.2: 23 files, 2.8M, built in 90 seconds ==> Installing gcc47 dependency: libmpc08 ==> Downloading http://multiprecision.org/mpc/download/mpc-0.8.1.tar.gz ######################################################################## 100.0% ==> ./configure --prefix=/usr/local/Cellar/libmpc08/0.8.1 --with-gmp=/usr/local/ ==> make ==> make check ==> make install ==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local. Conflicts with libmpc in main repository. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/libmpc08/lib CPPFLAGS: -I/usr/local/opt/libmpc08/include ==> Summary 🍺 /usr/local/Cellar/libmpc08/0.8.1: 10 files, 304K, built in 42 seconds ==> Installing gcc47 dependency: ppl011 ==> Downloading http://bugseng.com/products/ppl/download/ftp/releases/0.11/ppl-0 ######################################################################## 100.0% ==> Downloading https://gist.githubusercontent.com/manphiz/9507743/raw/45081e12c ######################################################################## 100.0% ==> Patching patching file configure ==> ./configure --prefix=/usr/local/Cellar/ppl011/0.11 --disable-silent-rules -- ==> make install ==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local. Conflicts with ppl in main repository. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/ppl011/lib CPPFLAGS: -I/usr/local/opt/ppl011/include ==> Summary 🍺 /usr/local/Cellar/ppl011/0.11: 1201 files, 43M, built in 4.5 minutes ==> Installing gcc47 dependency: cloog-ppl015 ==> Downloading ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-ppl-0.15.11.tar.g ######################################################################## 100.0% ==> ./configure --prefix=/usr/local/Cellar/cloog-ppl015/0.15.11 --with-gmp=/usr/ ==> make install ==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local. Conflicts with cloog in main repository. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/cloog-ppl015/lib CPPFLAGS: -I/usr/local/opt/cloog-ppl015/include ==> Summary 🍺 /usr/local/Cellar/cloog-ppl015/0.15.11: 21 files, 536K, built in 16 seconds ==> Installing gcc47 ==> Downloading http://ftpmirror.gnu.org/gcc/gcc-4.7.3/gcc-4.7.3.tar.bz2 ######################################################################## 100.0% ==> Patching patching file gcc/config/darwin.h patching file gcc/doc/tm.texi Hunk #1 succeeded at 9495 (offset 8 lines). patching file gcc/doc/tm.texi.in Hunk #1 succeeded at 9388 (offset 2 lines). patching file gcc/dwarf2out.c Hunk #1 succeeded at 22538 (offset 37 lines). patching file gcc/target.def Hunk #1 succeeded at 2758 (offset 10 lines). ==> ../configure --build=x86_64-apple-darwin13.4.0 --prefix=/usr/local/Cellar/gc ==> make bootstrap ==> make install 🍺 /usr/local/Cellar/gcc47/4.7.3: 1001 files, 127M, built in 32.0 minutes
いろいろ関連ファイルがインストールされました。しかも本番である gcc-4.7 のインストールには32分もかかりました…。
1.8.7インストール
$ CC=gcc-4.7 env CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline` --with-openssl-dir=`brew --prefix openssl`" rbenv install 1.8.7-p375 Checking out http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7... Installing ruby-1.8.7-p375... Installed ruby-1.8.7-p375 to /Users/riocampos/.rbenv/versions/1.8.7-p375 Downloading rubygems-1.6.2.tgz... -> http://dqw8nmjcqpjn7.cloudfront.net/cb5261818b931b5ea2cb54bc1d583c47823543fcf9682f0d6298849091c1cea7 Installing rubygems-1.6.2... Installed rubygems-1.6.2 to /Users/riocampos/.rbenv/versions/1.8.7-p375
確認
$ rbenv versions system 1.8.7-p375 * 1.9.3-p484 (set by /Users/riocampos/.rbenv/version) 1.9.3-p547 2.0.0-p481 2.1.2
インストール出来ました^^。