1

I'm using RVM, currently I'm using ruby 2.7.4

rvm current
ruby-2.7.4

I installed bundler -v 2.2.26 as default

gem install bundler -v2.2.26 --default
gem info bundler
*** LOCAL GEMS ***

bundler (2.2.26)
    Authors: André Arko, Samuel Giddins, Colby Swandale, Hiroshi
    Shibata, David Rodríguez, Grey Baker, Stephanie Morillo, Chris
    Morris, James Wen, Tim Moore, André Medeiros, Jessica Lynn Suttles,
    Terence Lee, Carl Lerche, Yehuda Katz
    Homepage: https://bundler.io
    License: MIT
    Installed at (default): /Users/jedrek/.rvm/rubies/ruby-2.7.4/lib/ruby/gems/2.7.0

When I check the location of the gem, it is not there.

ls /Users/jedrek/.rvm/rubies/ruby-2.7.4/lib/ruby/gems/2.7.0/gems
# no bundler gem

When I try to bundle my gems in my project I get an error

Traceback (most recent call last):
    3: from /Users/jedrek/.rvm/gems/ruby-2.7.4/bin/ruby_executable_hooks:22:in `<main>'
    2: from /Users/jedrek/.rvm/gems/ruby-2.7.4/bin/ruby_executable_hooks:22:in `eval'
    1: from /Users/jedrek/.rvm/gems/ruby-2.7.4/bin/bundle:23:in `<main>'
/Users/jedrek/.rvm/gems/ruby-2.7.4/bin/bundle:23:in `load': cannot load such file -- /Users/jedrek/.rvm/rubies/ruby-2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.2.26/exe/bundle (LoadError)

Where is my gem? What's going on?

jedi
  • 2,003
  • 5
  • 28
  • 66
  • what is the output of `gem list bundler` ? – lacostenycoder Oct 19 '21 at 18:36
  • I found in the internet that you can do `gem install bundler:2.2.26` and now it works. Very confusing. I still don't understand why it didn't work before. ``` gem list bundler *** LOCAL GEMS *** bundler (default: 2.2.27, 2.2.24, 2.1.4, 1.17.3, 1.14.0) ``` – jedi Oct 19 '21 at 19:09
  • Install the gem version with either syntax doesn't make a difference. My guess is you have multiple projects using different versions and perhaps you're switching around is not working as expected. You may want to try gemsets or chruby instead. See my answer below. – lacostenycoder Oct 20 '21 at 07:09

1 Answers1

2

Depending on if you have multiple projects on your system, when using RVM you may want to look into using gem sets as this can help with using correct versions when switching between project. However if you don't care about that, you can try uninstall the gem, then reinstall the version you want.

gem uninstall bundler # should uninstall all versions besides

#either of these two work the same
gem install bundler:2.2.26 
gem install bundler -v2.2.26

Personally I switched from using RVM to Chruby quite some time ago and have had far fewer issues like the one you described here.

lacostenycoder
  • 10,623
  • 4
  • 31
  • 48
  • Thanks. The syntax does make a difference because I tried installing with -v option and it didn't work. I installed with : syntax and it worked. I don't know why, though. – jedi Oct 20 '21 at 20:34
  • @jedi are you using an outdated version of ruby? see [this answer](https://stackoverflow.com/questions/17026441/ruby-how-to-install-a-specific-version-of-a-ruby-gem) for reference seems : syntax is for 1.9+ but still supported in 2.x – lacostenycoder Oct 20 '21 at 20:49
  • I am using ruby 2.7.4 with RVM – jedi Oct 21 '21 at 21:08