17
14

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 5 years have passed since last update.

rbenvでmacのrubyを最新にする

Last updated at Posted at 2016-08-24

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 して切り替えるのと変わらん。。)

参考)

17
14
2

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
17
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?