无法在rails控制台中使用bundler加载gem

时间:2017-06-30 18:39:13

标签: ruby-on-rails rubygems rvm bundler globalize

我正在尝试安装最新版本的Globalize gem - 唯一与Rails 5兼容的版本。为此,我必须从Github安装它。所以我按照自述文件的建议将以下行添加到Gemfile中:

gem 'globalize', git: 'https://github.com/globalize/globalize'

bundle install命令顺利执行。但是,gem list中没有显示globalize gem(我认为从Github安装的所有gems也没有显示),但显示在bundle list中。

当我运行bundle exec irb时,require 'globalize'工作正常。但它在rails console中不起作用。为什么?如何让gem可用于rails?

> rails c
2.4.0 :001 > require 'globalize'
LoadError: cannot load such file -- globalize
    from (irb):1
> gem env:
RubyGems Environment:
  - RUBYGEMS VERSION: 2.6.12
  - RUBY VERSION: 2.4.0 (2016-12-24 patchlevel 0) [x86_64-darwin16]
  - INSTALLATION DIRECTORY: /Users/wael/.rvm/gems/ruby-2.4.0@rails5
  - USER INSTALLATION DIRECTORY: /Users/wael/.gem/ruby/2.4.0
  - RUBY EXECUTABLE: /Users/wael/.rvm/rubies/ruby-2.4.0/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/wael/.rvm/gems/ruby-2.4.0@rails5/bin
  - SPEC CACHE DIRECTORY: /Users/wael/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/wael/.rvm/rubies/ruby-2.4.0/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-16
  - GEM PATHS:
     - /Users/wael/.rvm/gems/ruby-2.4.0@rails5
     - /Users/wael/.rvm/gems/ruby-2.4.0@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/wael/.rvm/gems/ruby-2.4.0@rails5/bin
     - /Users/wael/.rvm/gems/ruby-2.4.0@global/bin
     - /Users/wael/.rvm/rubies/ruby-2.4.0/bin
     - /Users/wael/.rvm/bin
....

rvm版本是1.29.2。 我在/Users/wael/.rvm/gems/ruby-2.4.0@rails5找不到globalize gem。

更新

> rvm gemset list
gemsets for ruby-2.4.0 (found in /Users/wael/.rvm/gems/ruby-2.4.0)
   (default)
   global
=> rails5

0 个答案:

没有答案