rvm による ruby 環境の自動切り替え の履歴(No.2)
更新rvmのgemsetを使ってbundlerと賢く付き合う方法†
これらを読むと、bundle exec が必要なくなるようなことが書いてある!
やってみる†
LANG:console $ rvm use 1.9 # ruby 1.9 を使う Using /home/osamu/.rvm/gems/ruby-1.9.3-p551 $ gem list | head # たくさんインストールされている actionmailer (4.0.8) actionpack (4.0.8) activemodel (4.0.8) activerecord (4.0.8) activerecord-deprecated_finders (1.0.4) activesupport (4.0.8) ansi (1.5.0) arel (6.0.3, 4.0.2) better_errors (1.1.0) bigdecimal (1.1.0) $ rvm gemset create ICSPM24 # 適当な名前で空の gemset を作成 ruby-1.9.3-p551 - #gemset created /home/osamu/.rvm/gems/ruby-1.9.3-p551@ICSPM24 ruby-1.9.3-p551 - #generating ICSPM24 wrappers........ $ rvm gemset use ICSPM24 # それを使う Using ruby-1.9.3-p551 with gemset ICSPM24 $ gem list # 自分でインストールしたものが消えた *** LOCAL GEMS *** bigdecimal (1.1.0) bundler (1.7.6) bundler-unload (1.0.2) executable-hooks (1.3.2) gem-wrappers (1.2.7) io-console (0.3) json (1.5.5) minitest (2.5.1) rake (0.9.2.2) rdoc (3.9.5) rubygems-bundler (1.4.4) rvm (1.11.3.9) $ which bundle # 正しいバージョンが使われることを確認 /home/osamu/.rvm/gems/ruby-1.9.3-p551@ICSPM24/bin/bundle $ bundle --version # 正しいバージョンが使われることを確認 Bundler version 1.7.6 $ bundle install --system # gem を導入する Fetching source index from https://rubygems.org/ ... $ gem list | head # 結果を確認 actionmailer (4.0.8) actionpack (4.0.8) activemodel (4.0.8) activerecord (4.0.8) activerecord-deprecated_finders (1.0.4) activesupport (4.0.8) ansi (1.5.0) arel (4.0.2) better_errors (1.1.0) bigdecimal (1.1.0) $ rvm gemset list # 現在の状況に合わせて gemsets for ruby-1.9.3-p551 (found in /home/osamu/.rvm/gems/ruby-1.9.3-p551) (default) => ICSPM24 global $ # 設定ファイルを作成 $ rvm --create --ruby-version use ruby-1.9.3-p551@ICSPM24 Using /home/osamu/.rvm/gems/ruby-1.9.3-p551 with gemset ICSPM24 $ cat .ruby-version # 中身を確認 ruby-1.9.3-p551 $ cat .ruby-gemset # 中身を確認 ICSPM24 $ cd .. # このフォルダの外で $ rvm use 2 Using /home/osamu/.rvm/gems/ruby-2.2.1 $ ruby --version # 違うバージョンの ruby と ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux] $ gem list | head -4 # gemset を使っていても actionmailer (4.2.6) actionpack (4.2.6) actionview (4.2.6) active_scaffold (3.4.35) $ cd ICSPM24 # 設定したフォルダに戻ると $ ruby --version # 正しいバージョンが使われる ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux] $ gem list | head -4 # gemset も actionmailer (4.0.8) actionpack (4.0.8) activemodel (4.0.8) activerecord (4.0.8)
これは便利だ。
質問・コメント†
Counter: 4368 (from 2010/06/03),
today: 1,
yesterday: 2