LoginSignup
2
2

More than 5 years have passed since last update.

複数バージョンのRubyを切り替えられるようにする

Last updated at Posted at 2019-03-24

rbenvというツールを使う。brewはインストール済み前提。
https://github.com/rbenv/rbenv

rbenvの導入

Macのターミナルで以下のコマンドを実行。

brew install rbenv
rbenv init
rbenv install -l # rubyのバージョン一覧を確認する。
rbenv install 2.6.2 # 2019/3/24時点の最新版をインストール
rbenv install 2.4.5 # 動作確認用に適当なバージョンをインストール
rbenv global 2.6.2 # 2.6.2を使うように設定

~/.bashrcに以下を記述。

export PATH=~/.rbenv/shims:$PATH

動作確認

Macのターミナルで以下のコマンドを実行。実際に2.6.2が選択されていることがわかる。

$ rbenv versions
  system
  2.4.5
* 2.6.2 (set by /Users/XXX/.rbenv/version)
$ ruby -v
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
2
2
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
2
2