wael34218
wael34218

Reputation: 4950

Cannot load gem installed using bundler in rails console

I am trying to install the latest version of Globalize gem - the only one compatible with Rails 5. To do that I have to install it from Github. So I added the following line to the Gemfile as suggested by the Readme file:

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

bundle install command is performed smoothly. But, globalize gem is not shown in gem list (I think all gems installed from Github does not show as well) but is shown in bundle list.

When I run bundle exec irb then require 'globalize' works fine. But it doesn't work in rails console. Why? How can I make the gem available for 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 version is 1.29.2. I couldn't find globalize gem in /Users/wael/.rvm/gems/ruby-2.4.0@rails5.


Update:

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

Upvotes: 2

Views: 1186

Answers (1)

user2386601
user2386601

Reputation: 121

I found this to resolve the issue for me:

> bundle exec rails console

Upvotes: 2

Related Questions