安装在@global gemset中的Gem在其他gemset中不可用

时间:2015-09-11 17:48:44

标签: ruby gem rvm gemset

我安装了rvm,然后在@global gemset中安装了bropages

$ rvm install 2.2.3
$ rvm use ruby-2.2.3@global
$ gem install bropages

当我跑步时

$ gem list | grep bro
bropages (0.1.0)

我可以看到安装了bropages。但是当我移动到默认的gemset时,它就不可用了。

$ rvm use ruby-2.2.3@default
$ gem list | grep bro # Result is empty

我也试过official way

$ rvm ruby-2.2.3@global do gem install bropages
Successfully installed bropages-0.1.0
Parsing documentation for bropages-0.1.0
Done installing documentation for bropages after 0 seconds
1 gem installed

但它也没有用。

在默认gemset中运行bro命令会出现此错误,

$ bro
/Users/andy/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'bropages' (>= 0) among 7 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/andy/.rvm/gems/ruby-2.2.3 /Users/andy/.rvm/gems/ruby-2.2.3@global:/Users/andy/.rvm/gems/ruby-2.2.3', execute `gem env` for more information
    from /Users/andy/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/dependency.rb:324:in `to_spec'
    from /Users/andy/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
    from /Users/andy/.rvm/gems/ruby-2.2.3@global/bin/bro:22:in `<main>'

我尝试过这些链接,但他们根本没有帮助。

  1. How to install gem across all gemsets when using RVM
  2. RVM - Not able to use gems from the @global gemset
  3. How do I use RVM and create globally available gems?
  4. Ruby 2.2.3是唯一安装的版本。我的贝壳是鱼。

    来自comment

      

    来自全局echo $GEM_HOME - $GEM_PATH

    的默认gemset:gemset run: gem list -d bro

    输出如下,

    $ rvm use ruby-2.2.3@default
    Using /Users/andy/.rvm/gems/ruby-2.2.3
    $ echo $GEM_HOME - $GEM_PATH
    /Users/andy/.rvm/gems/ruby-2.2.3 - /Users/andy/.rvm/gems/ruby-2.2.3 /Users/andy/.rvm/gems/ruby-2.2.3@global
    
    $ rvm use ruby-2.2.3@global
    Using /Users/andy/.rvm/gems/ruby-2.2.3 with gemset global
    $ gem list -d bro
    
    *** LOCAL GEMS ***
    
    bropages (0.1.0)
        Author: bropages.org
        Homepage: http://bropages.org
        Installed at: /Users/andy/.rvm/gems/ruby-2.2.3@global
    
        Bro
    

1 个答案:

答案 0 :(得分:2)

看起来您的GEM_PATH已损坏,请求运行:

export GEM_PATH=/Users/andy/.rvm/gems/ruby-2.2.3:/Users/andy/.rvm/gems/ruby-2.2.3@global

再试一次:

bro