248
226

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でrubyのバージョンを切り替える

Last updated at Posted at 2016-08-01

現在のrubyのバージョンを確認

$ ruby --version
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]

rbenvでインストールしてあるrubyのバージョン確認

$ rbenv versions
  system
  2.0.0-p195
* 2.1.1 (set by /Users/user_name/.rbenv/version)

rbenvでインストールできるrubyのバージョンを確認

$ rbenv install -l
Available versions:
  1.8.6-p383
  1.8.6-p420
  1.8.7-p249
  1.8.7-p302
  1.8.7-p334
  .
  .
  .

インストールしたいrubyのバージョンがリストにない場合

$ brew update
$ brew upgrade rbenv ruby-build

もっかい確認

$ rbenv install -l
Available versions:
  1.8.6-p383
  1.8.6-p420
  1.8.7-p249
  1.8.7-p302
  1.8.7-p334
  .
  .
  .
  2.1.5

インストール

$ rbenv install 2.1.5
Downloading ruby-2.1.5.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/4305cc6ceb094df55210d83548dcbeb5117d74eea25196a9b14fa268d354b100
Installing ruby-2.1.5...
Installed ruby-2.1.5 to /Users/user_name/.rbenv/versions/2.1.5

確認

$ rbenv versions
  system
  2.0.0-p195
* 2.1.1 (set by /Users/user_name/.rbenv/version)
  2.1.5

インストールしたバージョンに変更

$ rbenv local 2.1.5

確認

$ ruby --version
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin12.0]

おしまい。

と、思ったら

rails s
/Users/user_name/.rbenv/versions/2.1.5/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
	from /Users/user_name/.rbenv/versions/2.1.5/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/user_name/work/hyakuren/jamb_temp/config/boot.rb:4:in `<top (required)>'
	from bin/rails:7:in `require_relative'
	from bin/rails:7:in `<main>'

rails動かなくなったー。

cannot load such file -- bundler/setup (LoadError)

$ rbenv exec gem install bundle

これで動きました。

参考:
http://h2ham.net/ruby-rbenv
http://ylgbk.hatenablog.com/entry/2014/08/24/192707

248
226
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
248
226

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?