LoginSignup
51
47

More than 5 years have passed since last update.

ruby アップデートの仕方

Posted at

rbenvの確認

$ rbenv --version

ruby-buildのインストール

$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

これをやると、
$ rbenv install --listこれを実行した時に、

rubyのインストールできるバージョンの最新版が表示されるようになる。

自分が入れたいバージョンのrubyをインストールする

$ rbenv install --list  これで自分が入れたいrubyのバージョンを確認

$ rbenv install -v 2.3.1  これで、2.3.1がインストールされる。

インストールされているrubyのバージョンの確認

$ rbenv versions

* system (set by /Users/m.k/.rbenv/version)
  2.1.3
  2.3.1

この状態は、2.3.1をinstallしただけになっていて、まだ前のrubyのバージョンのままになっている。

バージョンを上げる

$ rbenv global 2.3.1

これをやれば、おk。

$ rbenv versions

* system (set by /Users/m.k/.rbenv/version)
  2.1.3
  2.3.1

・・・。
そう、pathを通さなければいけない。

環境設定

# PATH に追加
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

# .bash_profile に追加
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

# 上記設定の再読み込み
$ exec $SHELL -l

これで、

$ rbenv versions

  system
  2.1.3
* 2.3.1 (set by /Users/m.k/.rbenv/version)

無事、バージョンアップ完了。

51
47
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
51
47