げっとシステムログ

WEB開発メモ

CentOS7 に ruby 2.0.0-p481 をインストールする

以下、 CentOS7 に ruby 2.0.0-p481 をインストールした記録

もともと他の用途でセットアップしてあって、初期状態じゃないです
あと、 CentOS7 だけど sudo できるようにしてある

rbenv はインストール済みでした

作業開始

とりあえずインストールしてみる

[shun ~]$ rbenv install 2.0.0-p481
Downloading ruby-2.0.0-p481.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p481.tar.bz2
/home/shun/.rbenv/plugins/ruby-build/bin/ruby-build: 209 行: pushd: ruby-2.0.0-p481: そのようなファイルやディレクトリはありません

BUILD FAILED (CentOS Linux 7 using ruby-build 20160228-5-g522f3ba)

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

Last 10 log lines:
/tmp/ruby-build.20160312105538.13932 ~
warning: bzip2 not found; consider installing `bzip2` package
tar (child): bzip2: exec 不能: そのようなファイルやディレクトリはありません
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

bzip2 がない

[shun ~]$ sudo yum install bzip2

さらにインストール

[shun ~]$ rbenv install 2.0.0-p481
Downloading ruby-2.0.0-p481.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p481.tar.bz2
Installing ruby-2.0.0-p481...

BUILD FAILED (CentOS Linux 7 using ruby-build 20160228-5-g522f3ba)

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

Last 10 log lines:
/tmp/ruby-build.20160312105655.14105/ruby-2.0.0-p481 /tmp/ruby-build.20160312105655.14105 ~
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/ruby-build.20160312105655.14105/ruby-2.0.0-p481':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

gcc がない

[shun ~]$ sudo yum install gcc

もう一度

[shun ~]$ rbenv install 2.0.0-p481
Downloading ruby-2.0.0-p481.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p481.tar.bz2
Installing ruby-2.0.0-p481...

BUILD FAILED (CentOS Linux 7 using ruby-build 20160228-5-g522f3ba)

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

Last 10 log lines:
The Ruby openssl extension was not compiled.
The Ruby readline extension was not compiled.
The Ruby zlib extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try running `yum install -y openssl-devel readline-devel zlib-devel` to fetch missing dependencies.

Configure options used:
  --prefix=/home/shun/.rbenv/versions/2.0.0-p481
  LDFLAGS=-L/home/shun/.rbenv/versions/2.0.0-p481/lib
  CPPFLAGS=-I/home/shun/.rbenv/versions/2.0.0-p481/include

今度は yum しろって言われました

[shun ~]$ sudo yum install openssl-devel readline-devel zlib-devel

今度こそ

[shun ~]$ rbenv install 2.0.0-p481
Downloading ruby-2.0.0-p481.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p481.tar.bz2
Installing ruby-2.0.0-p481...
Installed ruby-2.0.0-p481 to /home/shun/.rbenv/versions/2.0.0-p481

Fetching: bundler-1.11.2.gem (100%)
Successfully installed bundler-1.11.2
Parsing documentation for bundler-1.11.2
Installing ri documentation for bundler-1.11.2
1 gem installed

インストールされました

bundler がインストールされるのは rbenv-default-gems 使ってるからです

github.com

確認

[shun ~]$ ruby -v
rbenv: ruby: command not found

The `ruby' command exists in these Ruby versions:
  2.0.0-p481

おや?

そうか。 ruby-version がなかった

[shun ~]$ cd work/
[shun work]$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [x86_64-linux]

完了です