LoginSignup
13
12

More than 5 years have passed since last update.

rbenv で Ruby2.1.2 がインストールできなかった話

Last updated at Posted at 2016-01-26

なにが起きたの?

lodgeを使ってみようと思い、RubyRailsをインストールしたのだが、
Ruby2.2.xではエラーが出るとの情報を発見。
既にRuby2.2.3をインストールしてしまっていたので、Ruby2.1.2をインストールしようとしたところ。。。

[root@lodge lodge]# rbenv install 2.1.2
Downloading ruby-2.1.2.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/f22a6447811a81f3c808d1c2a5ce3b5f5f0955c68c9a749182feb425589e6635
Installing ruby-2.1.2...

BUILD FAILED (CentOS 6.7 using ruby-build 20151028-11-gbd22205)

Inspect or clean up the working tree at /tmp/ruby-build.20151125183251.20710
Results logged to /tmp/ruby-build.20151125183251.20710.log

Last 10 log lines:
installing rdoc:              /opt/rbenv/versions/2.1.2/share/ri/2.1.0/system
installing capi-docs:         /opt/rbenv/versions/2.1.2/share/doc/ruby
The Ruby readline extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try running `yum install -y readline-devel` to fetch missing dependencies.

Configure options used:
  --prefix=/opt/rbenv/versions/2.1.2
  LDFLAGS=-L/opt/rbenv/versions/2.1.2/lib
  CPPFLAGS=-I/opt/rbenv/versions/2.1.2/include

解決策

下記メッセージにあるようにreadline-develをインストール

ERROR: Ruby install aborted due to missing extensions
Try running `yum install -y readline-devel` to fetch missing dependencies.
[root@lodge lodge]# yum install readline-devel

再度、Ruby2.1.2のインストールを実施

[root@lodge lodge]# rbenv install 2.1.2
Downloading ruby-2.1.2.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/f22a6447811a81f3c808d1c2a5ce3b5f5f0955c68c9a749182feb425589e6635
Installing ruby-2.1.2...
Installed ruby-2.1.2 to /opt/rbenv/versions/2.1.2

現在どのバージョンのRubyが使用されているか確認

[root@lodge rails]# rbenv versions
  system
  2.1.2
* 2.2.3 (set by /opt/rbenv/version)

インストールしたRuby2.1.2に切り換える

[root@lodge rails]# rbenv global 2.1.2

切り替わっているか確認

[root@lodge rails]# rbenv versions
  system
* 2.1.2 (set by /opt/rbenv/version)
  2.2.3

でけた!

13
12
0

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
13
12