LoginSignup
10
10

More than 5 years have passed since last update.

rbenvでruby2.1.0-devがインストールできなかったのでなんとかしたメモ

Last updated at Posted at 2013-12-15

ruby2.1.0でrails4を動かして
pry>>Gem::VERSIONを調べたいなと思っていたら出だしでハマった。

zsh

/usr/local/rbenv% rbenv install 2.1.0-dev

Downloading openssl-1.0.1e.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/66bf6f10f060d561929de96f9dfe5b8c
Installing openssl-1.0.1e...
Installed openssl-1.0.1e to /usr/local/rbenv/versions/2.1.0-dev

Cloning https://github.com/ruby/ruby.git...
Installing ruby-2.1.0-dev...

BUILD FAILED

Inspect or clean up the working tree at /var/folders/g3/w0tng20j6b7_1p82k5x9fmr00000gn/T/ruby-build.20131215142636.47645
Results logged to /var/folders/g3/w0tng20j6b7_1p82k5x9fmr00000gn/T/ruby-build.20131215142636.47645.log

Last 10 log lines:
cp libssl.pc /usr/local/rbenv/versions/2.1.0-dev/openssl/lib/pkgconfig
chmod 644 /usr/local/rbenv/versions/2.1.0-dev/openssl/lib/pkgconfig/libssl.pc
cp openssl.pc /usr/local/rbenv/versions/2.1.0-dev/openssl/lib/pkgconfig
chmod 644 /usr/local/rbenv/versions/2.1.0-dev/openssl/lib/pkgconfig/openssl.pc
/var/folders/g3/w0tng20j6b7_1p82k5x9fmr00000gn/T/ruby-build.20131215142636.47645 /usr/local/rbenv
/usr/local/rbenv
/var/folders/g3/w0tng20j6b7_1p82k5x9fmr00000gn/T/ruby-build.20131215142636.47645 /usr/local/rbenv
Cloning into 'ruby-2.1.0-dev'...
/var/folders/g3/w0tng20j6b7_1p82k5x9fmr00000gn/T/ruby-build.20131215142636.47645/ruby-2.1.0-dev /var/folders/g3/w0tng20j6b7_1p82k5x9fmr00000gn/T/ruby-build.20131215142636.47645 /usr/local/rbenv
/usr/local/rbenv/plugins/ruby-build/bin/ruby-build: line 393: autoconf: command not found

ruby-buildというシェルスクリプトの中でautoconfというコマンドが上手くいってないらしい。

あとopensslがなかったのでbrew installしといた

rbenv install 2.1.0-dev

すると進展アリ。

autoconfとは

移植性の高いソフトウェアを開発するには対応するシステムに対する深い知識が必要になりますが、開発者自身が、インストールされる可能性のあるすべてのシステム固有の問題を考慮しながら開発するのは極めて困難です。>autoconfをはじめとする一連のツール群はそういった固有の問題を回避するための雛形を作成し、スムーズにより移植性の高いプログラムの開発をサポートするツール群です。

autoconfの使用方法より

というわけなので
brew install autoconf
しておく
.zshrcでexport PATH="/usr/local/Cellar/autoconf/2.69/bin:$PATH"
にPATHも通しておかないとautoconfコマンドは使えない

zsh

/usr/local/rbenv% RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/local/Cellar/openssl/1.0.1e rbenv install 2.1.0-dev

Cloning https://github.com/ruby/ruby.git...
Installing ruby-2.1.0-dev...

BUILD FAILED

Inspect or clean up the working tree at /var/folders/g3/w0tng20j6b7_1p82k5x9fmr00000gn/T/ruby-build.20131215152037.8494
Results logged to /var/folders/g3/w0tng20j6b7_1p82k5x9fmr00000gn/T/ruby-build.20131215152037.8494.log

Last 10 log lines:
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for cd using physical directory... cd -P
checking whether CFLAGS is valid... yes
checking whether LDFLAGS is valid... no
configure: error: something wrong with LDFLAGS="-L'/usr/local/rbenv/versions/2.1.0-dev/lib' "

BUILD FAILED

Inspect or clean up the working tree at /var/folders/g3/w0tng20j6b7_1p82k5x9fmr00000gn/T/ruby-build.20131215152037.8494
Results logged to /var/folders/g3/w0tng20j6b7_1p82k5x9fmr00000gn/T/ruby-build.20131215152037.8494.log

Last 10 log lines:
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for cd using physical directory... cd -P
checking whether CFLAGS is valid... yes
checking whether LDFLAGS is valid... no
configure: error: something wrong with LDFLAGS="-L'/usr/local/rbenv/versions/2.1.0-dev/lib' "
make: *** No targets specified and no makefile found.  Stop.


エラーメッセージが変わった。
LDFLAGSライブラリパスを指定するための環境変数のようだ。
/usr/local/rbenv/versions/2.1.0-dev/lib
をチェックしてみる。

/usr/local/rbenv/versions
に2.1.0-devフォルダがそもそも存在しないのが問題なので、もっと前に問題は発生しているっぽい。

より前のrubyのバージョンでBUILD FAILEDが出るときはgccのpathや、pkgのバージョンが問題のきっかけらしいが、ruby2.1.0はどうだろうか。

エラーメッセージでググると自分の記事が出る絶望感を味わいながらもう少し考える。


追記

LDFLAGS="-L'/usr/local/rbenv/versions/2.1.0-dev/lib' "
に問題があるが

Cloning https://github.com/ruby/ruby.git
に失敗している。

手動で
/usr/local/rbenv/versionsにruby2.1.0-devをクローンして進めるか・・・


追記2

rbenv install -l

2.0.0p-353
がリストに入っていないのがおかしいと思ったので

rbenvとruby-buildでRuby環境を最新に保つのんを参考に

zsh

$ cd /usr/local/rbenv
$ git pull origin master
$ cd /usr/local/rbenv/plugins/ruby-build
$ git pull origin master

するとrbenvとruby-buildを最新版にできた。

続いて

rbenv install 2.1.0-preview2

が通った。

しかし

zsh
rbenv global 2.1.0-preview2                           
rbenv versions             
   system
   2.0.0-p195
   2.0.0-p247
* 2.1.0-preview2 (set by /usr/local/rbenv/version)
rbenv rehash               
ruby -v
#=> ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]

うーむ
「preview2は使えないけどdev/preview1が使える」などあるのだろうか。


追記3

.zshrc

export RBENV_ROOT=/usr/local/rbenv

している状態で

export PATH=$RBENV_ROOT/shims:$PATH

をコマンドラインで打ってやると

(効果あるかわからんけど/usr/local/rbenv/versions/2.0.0-p247% cp -a shims ../2.1.0-preview1/shimsだけしといた)

rbenv globalで正常にrubyのバージョンが変更できました。

ruby 2.1.0dev (2013-09-22 trunk 43011) [x86_64-darwin12.4.0]

10
10
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10