rvm による ruby 環境の自動切り替え のバックアップ(No.1)

更新


公開メモ

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
 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 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
$ gem list | head -4
 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
 actionmailer (4.0.8)
 actionpack (4.0.8)
 activemodel (4.0.8)
 activerecord (4.0.8)

これは便利だ。


Counter: 3816 (from 2010/06/03), today: 2, yesterday: 3