0

After the MimeMagic dependency fiasco, I'm now unable to generate a model in Rails. I've got the following warning message and stack trace error after trying to generate a User model in rails

rails generate model User email:string 
password_digest:string
Warning: the running version of Bundler (2.2.3) is 
older than the version that created the lockfile 
(2.2.15). We suggest you to upgrade to the version 
that created the lockfile by running `gem install 
bundler:2.2.15`.

However, my Gemfile is updated to 2.2.15 and I've run bundle install again to no avail.

Here is part of the stack trace error after that Warning:

/Users/shmeadyy/Desktop/Projects/scheduled_tweets/vendor/bundle/ruby/3.0.0/gems/msgpack-1.4.2/lib/msgpack.rb:8:in `require': incompatible library version - /Users/shmeadyy/Desktop/Projects/scheduled_tweets/vendor/bundle/ruby/3.0.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle (LoadError)
        from /Users/shmeadyy/Desktop/Projects/scheduled_tweets/vendor/bundle/ruby/3.0.0/gems/msgpack-1.4.2/lib/msgpack.rb:8:in `<top (required)>'
        from /Users/shmeadyy/Desktop/Projects/scheduled_tweets/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/store.rb:4:in `require'
        from /Users/shmeadyy/Desktop/Projects/scheduled_tweets/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/store.rb:4:in `block in <top (required)>'
Laura Thorson
  • 245
  • 1
  • 2
  • 6
  • Have you tried to just delete the ```gemfile.lock``` and regenerate it with ```bundle install``` ? – Sebi Mar 31 '21 at 16:33
  • yep, tried that a couple of times without success. i don't understand what's going on because i've got the newest version of bundler on my machine when i check the version number, and when i do a new `bundle install` it says that it's been BUNDLED WITH the latest. – Laura Thorson Mar 31 '21 at 21:24
  • https://stackoverflow.com/questions/9725811/how-to-downgrade-bundler-or-upgrade-rails – Sebi Apr 02 '21 at 13:13

1 Answers1

0

The bundler used to generate Gemfile is the one globally installed in your ruby gems directory.

gem environment

and

gem list

will give you more information about your current ruby and gems installation.

You probably added older version of bundler into gemfile, and using bundle command you've switched to an older version.

You can try to update global version of bundler by running the prompted

gem install bundler:2.2.15

In my opinion you should remove bundler entry from gemfile, as each time you'd use bundle command it will switch back to older version unnecessarily.

LE-HU
  • 631
  • 5
  • 17
  • when i look at my `gem list` i can see that i have `bundler (2.2.15, 2.2.5)`. so if i remove `BUNDLED WITH 2.2.15` from my Gemfile.lock - will that help? I notice that in my Gemfile.lock I have `bundler (>= 1.15.0)` in there - is that the problem? – Laura Thorson Mar 29 '21 at 20:31
  • I'd rather do `gem install bundler:2.2.15` and operate on the same version of bundler that was used to generate Gemfile.lock. Is there any reason you'd rather stick to the older version? Do you have gem 'bundler' entry in regular Gemfile? – LE-HU Mar 29 '21 at 20:34
  • I don't care what bundler version I'm using tbh. I haven't worked in Rails in a number of years at this point, so I don't really know how to remove the old version? Is it as easy as removing it? There is no bundler entry in the Gemfile. – Laura Thorson Mar 30 '21 at 17:47