1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Mac に rbenv を入れてバージョン管理

Last updated at Posted at 2020-11-19

テスト用の環境とローカル(Mac)で Ruby のバージョンが違っていたため、 rbenv を使って合わせる。rbenv は Ruby のバージョン管理ツール。

  • テスト環境: 2.4.1
  • ローカル環境: 2.3.1
# はじめにローカル(Mac)側のバージョンを確認
$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

# rbenv をインストール
$ brew install rbenv ruby-build

# 今使っている Ruby のバージョンを確認
# system というのは Mac に最初から入っているやつを使っているよ、の意味
$ rbenv versions
* system (set by /Users/takiguchi-yu/.rbenv/version)

# インストール可能なバージョンを確認
$ rbenv install -l
# ※ 全てのバージョンを確認する場合は以下のコマンド
$ rbenv install --list-all

# 今回インストールしたいバージョンを指定してインストール
$ rbenv install 2.4.1

# 現在の Ruby のバージョンを今インストールしたバージョンに変更する
$ rbenv global 2.4.1
$ rbenv versions
  system
* 2.4.1 (set by /Users/takiguchi-yu/.rbenv/version)

Ruby の開発をするなら rbenv-communal-gems も入れておいた方が良いらしいです。

rbenvでインストールされたrubyのgemsディレクトリを共有化することができるヤツです
これないとrubyのversion up対応の時にgemの入れ直しをしないといけなかったりして酷い目に合います

github rbenv-communal-gems公式

引用:https://qiita.com/Alex_mht_code/items/d2db2eba17830e36a5f1

$ brew install rbenv-communal-gems

最後にパスを通して終わり。

~/.bash_profile

# rbenv PATH

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?