简体   繁体   English

升级到 Ruby 2.5.1 后的问题 - “库版本不兼容”

[英]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 .使用 Homebrew 升级到 Ruby 2.5.1 后,我在pg创建数据库时遇到问题。

When I run rake db:create for the first time, the rake is aborted with an error like:当我第一次运行rake db:create时,rake 被中止并出现如下错误:

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:

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) ).我还检查了我的 Gemfile,并且我安装了最近的 Rails 版本( rails (5.2.0) )。

Have not found any similar issues on Stack Overflow or elsewhere.在 Stack Overflow 或其他地方没有发现任何类似的问题。 Any idea where to begin with this one?知道从哪里开始吗?

This may be a pg gem version problem.这可能是pg gem 版本问题。 Use gem 'pg', '~> 0.21.0' in your Gemfile then do the bundle install .在 Gemfile 中使用gem 'pg', '~> 0.21.0'然后执行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.在将 Ruby 应用程序从 ruby​​ 2.4 升级到 2.6 后,我只花了几个小时在一个非常相似的错误上。 I'm using rbenv and bundler on MacOS Mojave.我在 MacOS Mojave 上使用 rbenv 和 bundler。

I uninstalled about a dozen old versions of ruby and started clean.我卸载了大约十几个旧版本的 ruby​​ 并开始清理。 This got me past the exact error in the question.这让我克服了问题中的确切错误。

This may be overkill, but it worked for me:这可能有点矫枉过正,但对我有用:

List all installed ruby versions:列出所有已安装的 ruby​​ 版本:

rbenv versions

Uninstall all versions of Ruby.卸载所有版本的 Ruby。

rbenv uninstall 2.1
rbenv uninstall 2.1.9
etc.

Install needed version(s) of Ruby安装所需的 Ruby 版本

rbenv install

bundle install

I tried running my app after bundle install and got dozens of warnings like these:我尝试在bundle install后运行我的应用程序,并收到了几十个这样的警告:

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

% 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.运行bundle看起来成功了,但没有更新 Gemfile.lock,也没有解决问题。

Finally, restoring all the gems to pristine solved the problem:最后,将所有宝石恢复到原始状态解决了问题:

gem pristine --all

I could now run the app, rake, etc.我现在可以运行应用程序、rake 等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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