Help us understand the problem. What is going on with this article?

rbenvでmacのrubyを最新にする

rbenv install [バージョン]だけでは切り替わらなかったので、対応方法の備忘録。

インストール

$ brew update
$ brew install rbenv ruby-build

# 既にinstallしている場合はupgrade
$ brew upgrade rbenv ruby-build

$ rbenv install --list
$ rbenv install 2.3.1

確認

$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]

変わらず。。

version確認。

$ rbenv versions
* system
  2.3.1 (set by /Users/kogache/.rbenv/version)

system??

デフォルトのバージョンを固定したい場合は global を使う。すると ~/.rbenv/version に使うバージョンが書き込まれる。らしい。。

$ rbenv global 2.3.1
$ rbenv versions
  system
* 2.3.1 (set by /Users/kogache/.rbenv/version)

確認。

$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]

まだ変わらず。。

コマンドのpathを確認。

$ which ruby
/usr/bin/ruby

path が正しくなかったよう。
rbenv のrubyを使う場合は、
/Users/ユーザー/.rbenv/shims/ruby
に設定される必要があるとのこと。

$ rbenv init
# Load rbenv automatically by appending
# the following to ~/.bash_profile:

eval "$(rbenv init -)"

eval "$(rbenv init -)"~/.bash_profile に追記。

$ vim ~/.bash_profile
$ source ~/.bash_profile
$ which ruby
/Users/ユーザー/.rbenv/shims/ruby
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin11.0]

ヽ(=´▽`=)ノ

(ふつーに brew install して切り替えるのと変わらん。。)

参考)
- rbenvでバージョンがうまく切り替わらなかった時にやったこと - Qiita
- rbenvでRubyのバージョンを指定する方法 - Qiita
- brew upgrade rbenv ruby-build

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away