rbenvとruby-buildでRubyのインストール環境を揃える
- gitをインストール
1 |
yum install -y git |
- gitをインストールしたら次にrbenvをインストール
1 |
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv |
1 |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile |
1 |
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile |
1 |
source ~/.bash_profile |
ruby-buildをインストール
1 |
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build |
1 |
cd ~/.rbenv/plugins/ruby-build |
1 |
./install.sh |
Ruby 2.3.1をインストール
1 2 3 4 5 6 7 8 |
rbenv install -l 実行結果 2.3.1 2.4.0-dev . . . |
- はじめにrubyの依存パッケージをインストール
1 |
yum install -y bzip2 make gcc openssl-devel readline-devel zlib-devel |
- rubyをインストール
1 |
rbenv install 2.3.1 |
- gemでインストールした実行ファイルを実行するようにする
1 |
rbenv rehash |
globalでrubyの実行versionを指定
1 |
rbenv global 2.3.1 |
- 最後に確認
1 2 3 4 |
ruby -v 実行結果 ruby 2.3.1p112 (2016-04-26 revision 54768) |
※ whichが無い場合は
1 |
yum install -y which |
1 2 3 4 |
which ruby 実行結果 ~/.rbenv/shims/ruby |
1 2 3 4 |
which gem 実行結果 ~/.rbenv/shims/gem |
Tweet
