2

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
wael34218
  • 4,860
  • 8
  • 44
  • 62
  • Try adding "require 'globalize' " to config/application.rb – William Holt Jun 30 '17 at 18:43
  • Unfortunately that didn't work :/ – wael34218 Jun 30 '17 at 18:49
  • What do you get when you do `rvm gemset list`? – jvillian Jun 30 '17 at 19:05
  • @jvillian `rvm gemset list` output is added to the question – wael34218 Jun 30 '17 at 19:15
  • 1
    @wael34218: As per the documentation you have to install `activemodel-serializers-xml` too. please refer this doc. https://github.com/globalize/globalize#installation – Ajay Barot Jun 30 '17 at 19:16
  • Thanks @AjayBarot, but it is already added. I just didn't write about it, because I thought it is irrelevant to the problem of requiring globalize. – wael34218 Jun 30 '17 at 19:20
  • 1
    @wael34218: ok. I have same configuration in my machine. `rvm 1.29.11 and ruby-2.4.0`. and I am able to require globalize gem in console. Strange. Try this Remove Gemfile.lock and `bundle install` again. – Ajay Barot Jun 30 '17 at 19:27
  • @AjayBarot I tried your suggestion, but that didn't work :( Did you create a new gemset? Or using default one? – wael34218 Jun 30 '17 at 19:37
  • Try running 'bundle exec rails console' instead of 'rails console'. – Dharam Gollapudi Jun 30 '17 at 19:40
  • 1
    @wael34218: created new gemset for rails5. and then install rails 5 using `gem install rails -v '5.0.2' then rvm gemset use rails5(name of gemset)` and `bundle install`. – Ajay Barot Jun 30 '17 at 19:41
  • @Dharam I tried that but it isn't working either – wael34218 Jun 30 '17 at 19:46
  • @AjayBarot ok there is something weird going on. I will try making a new gemset and doing it over again. My current Rails version is `5.1.2` so might as well try `5.0.2` this time. – wael34218 Jun 30 '17 at 19:48
  • 1
    @AjayBarot I created new gemset and new Rails project with only globalize lines added to the Gemfile. It worked fine on both 5.1.2 and 5.0.2, require command loaded the library as expected. Since I just started this project I think ill just build up on the new one. Thanks for your help! – wael34218 Jun 30 '17 at 20:07

1 Answers1

2

I found this to resolve the issue for me:

> bundle exec rails console
user2386601
  • 101
  • 6