使用RVM时,如果在不同的ruby版本中安装gem,则bundler不会安装在正确的gemset中

时间:2010-12-11 02:52:09

标签: ruby bundler rvm

我遇到了rvm,bundler和gemsets的问题。我在rvm中安装了3个红宝石:

rvm rubies

   macruby-0.7.1 [ x86_64 ]
   ree-1.8.7-2010.02 [ x86_64 ]
=> ruby-1.9.2-p0 [ x86_64 ]

和宝石一样:

rvm gemsets

   macruby-0.7.1 [ x86_64 ]
   ree-1.8.7-2010.02 [ x86_64 ]
   ree-1.8.7-2010.02@chef [ x86_64 ]
   ree-1.8.7-2010.02@global [ x86_64 ]
   ree-1.8.7-2010.02@mobi [ x86_64 ]
   ree-1.8.7-2010.02@temple_rails [ x86_64 ]
   ruby-1.9.2-p0 [ x86_64 ]
=> ruby-1.9.2-p0@instapaper [ x86_64 ]
   ruby-1.9.2-p0@mobi [ x86_64 ]

我有一个.rvmrc切换到ruby 1.9.2和“instapaper”gemset:

rvm use ruby-1.9.2-p0@instapaper

我想使用bundler,所以我在这个gemset中手动安装bundler,并且工作正常。

我构建我的Gemfile:

source "http://rubygems.org"
gem "mechanize"
gem "highline"
gem "www-delicious"

然后当我运行“bundle install”时,它使用它在ree 1.8.7中看到的宝石:

Using highline (1.6.1) 
Using nokogiri (1.4.4) 
Using mechanize (1.0.0) 
Using www-delicious (0.4.0) 
Using bundler (1.0.7) 
Your bundle is complete! It was installed into /Users/kold/.rvm/gems/ree-1.8.7-2010.02

如果我运行“rvm info”,它会发出所有正确的信息,我甚至可以手动安装gem而不会出现问题:

kold@Kevin-Olds-MacBook-Pro [master*]$ rvm info

ruby-1.9.2-p0@instapaper:

  system:
    uname:       "Darwin Kevin-Olds-MacBook-Pro.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386 i386"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
    zsh:         "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"

  rvm:
    version:      "rvm 1.1.0 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.2p0"
    date:         "2010-08-18"
    platform:     "x86_64-darwin10.4.0"
    patchlevel:   "2010-08-18 revision 29036"
    full_version: "ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]"

  homes:
    gem:          "/Users/kold/.rvm/gems/ruby-1.9.2-p0@instapaper"
    ruby:         "/Users/kold/.rvm/rubies/ruby-1.9.2-p0"

  binaries:
    ruby:         "/Users/kold/.rvm/rubies/ruby-1.9.2-p0/bin/ruby"
    irb:          "/Users/kold/.rvm/rubies/ruby-1.9.2-p0/bin/irb"
    gem:          "/Users/kold/.rvm/rubies/ruby-1.9.2-p0/bin/gem"
    rake:         "/Users/kold/.rvm/rubies/ruby-1.9.2-p0/bin/rake"

  environment:
    PATH:         "/Users/kold/.rvm/gems/ruby-1.9.2-p0@instapaper/bin:/Users/kold/.rvm/gems/ruby-1.9.2-p0@global/bin:/Users/kold/.rvm/rubies/ruby-1.9.2-p0/bin:/Users/kold/.rvm/bin:/usr/local/bin:/usr/local/mysql/bin:/opt/local/bin:/Users/kold/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin"
    GEM_HOME:     "/Users/kold/.rvm/gems/ruby-1.9.2-p0@instapaper"
    GEM_PATH:     "/Users/kold/.rvm/gems/ruby-1.9.2-p0@instapaper:/Users/kold/.rvm/gems/ruby-1.9.2-p0@global"
    MY_RUBY_HOME: "/Users/kold/.rvm/rubies/ruby-1.9.2-p0"
    IRBRC:        "/Users/kold/.rvm/rubies/ruby-1.9.2-p0/.irbrc"
    RUBYOPT:      ""
    gemset:       "instapaper"

我只是不确定为什么要在gemset之外安装这些宝石。

更新1:

$ rvm use ruby-1.9.2-p0@instapaper && which bundle
Using /Users/kold/.rvm/gems/ruby-1.9.2-p0 with gemset instapaper
/Users/kold/.rvm/gems/ruby-1.9.2-p0@instapaper/bin/bundle

kold@Kevin-Olds-MacBook-Pro [master*]$ bundle --verbose check
Using highline (1.6.1) from /Users/kold/.rvm/gems/ree-1.8.7-2010.02/specifications/highline-1.6.1.gemspec 
Using nokogiri (1.4.4) from /Users/kold/.rvm/gems/ree-1.8.7-2010.02/specifications/nokogiri-1.4.4.gemspec 
Using mechanize (1.0.0) from /Users/kold/.rvm/gems/ree-1.8.7-2010.02/specifications/mechanize-1.0.0.gemspec 
Using www-delicious (0.4.0) from /Users/kold/.rvm/gems/ree-1.8.7-2010.02/specifications/www-delicious-0.4.0.gemspec 
Using bundler (1.0.7) from /Users/kold/.rvm/gems/ruby-1.9.2-p0@instapaper/gems/bundler-1.0.7/lib/bundler 
Your bundle is complete! It was installed into /Users/kold/.rvm/gems/ree-1.8.7-2010.02

1 个答案:

答案 0 :(得分:5)

在IRC上与#bundler上的“间接”交谈后,我们确定我的BUNDLE_PATH设置为/Users/kold/.rvm/gems/ree-1.8.7-2010.02。一旦我做了unset BUNDLE_PATH,一切都按预期工作!