简体   繁体   中英

Issues after upgrading to Ruby 2.5.1 - “Incompatible library version”

After using Homebrew to upgrade to Ruby 2.5.1, I am having issues creating my database in pg .

When I run rake db:create for the first time, the rake is aborted with an error like:

rake db:create 
rake aborted!
LoadError: incompatible library version - /Users/jp/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.0/lib/bootsnap/bootsnap.bundle
/Users/jp/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/jp/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/jp/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'

I've confirmed that I have that version of Ruby running:

ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

I've also checked my Gemfile, and I have a recent Rails version installed ( rails (5.2.0) ).

Have not found any similar issues on Stack Overflow or elsewhere. Any idea where to begin with this one?

This may be a pg gem version problem. Use gem 'pg', '~> 0.21.0' in your Gemfile then do the bundle install . This will resolve.

I just spend several hours on a very similar error, after upgrading a Ruby app from ruby 2.4 to 2.6. I'm using rbenv and bundler on MacOS Mojave.

I uninstalled about a dozen old versions of ruby and started clean. This got me past the exact error in the question.

This may be overkill, but it worked for me:

List all installed ruby versions:

rbenv versions

Uninstall all versions of Ruby.

rbenv uninstall 2.1
rbenv uninstall 2.1.9
etc.

Install needed version(s) of Ruby

rbenv install

bundle install

I tried running my app after bundle install and got dozens of warnings like these:

Ignoring binding_of_caller-0.8.0 because its extensions are not built.  Try: gem pristine binding_of_caller --version 0.8.0
Ignoring binding_of_caller-0.7.2 because its extensions are not built.  Try: gem pristine binding_of_caller --version 0.7.2
Ignoring bootsnap-1.4.6 because its extensions are not built.  Try: gem pristine bootsnap --version 1.4.6

At that time, I could not run bundle exec rake

% bundle exec rake
bundler: command not found: rake
Install missing gem executables with `bundle install`

Running bundle appeared successful, but did not update Gemfile.lock, and did not fix the problem.

Finally, restoring all the gems to pristine solved the problem:

gem pristine --all

I could now run the app, rake, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM