[英]Issues after upgrading to Ruby 2.5.1 - “Incompatible library version”
使用 Homebrew 升级到 Ruby 2.5.1 后,我在pg
创建数据库时遇到问题。
当我第一次运行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'
我已经确认我正在运行那个版本的 Ruby:
ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
我还检查了我的 Gemfile,并且我安装了最近的 Rails 版本( rails (5.2.0)
)。
在 Stack Overflow 或其他地方没有发现任何类似的问题。 知道从哪里开始吗?
这可能是pg
gem 版本问题。 在 Gemfile 中使用gem 'pg', '~> 0.21.0'
然后执行bundle install
。 这将解决。
在将 Ruby 应用程序从 ruby 2.4 升级到 2.6 后,我只花了几个小时在一个非常相似的错误上。 我在 MacOS Mojave 上使用 rbenv 和 bundler。
我卸载了大约十几个旧版本的 ruby 并开始清理。 这让我克服了问题中的确切错误。
这可能有点矫枉过正,但对我有用:
列出所有已安装的 ruby 版本:
rbenv versions
卸载所有版本的 Ruby。
rbenv uninstall 2.1
rbenv uninstall 2.1.9
etc.
安装所需的 Ruby 版本
rbenv install
bundle install
我尝试在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
当时,我无法运行bundle exec rake
% bundle exec rake
bundler: command not found: rake
Install missing gem executables with `bundle install`
运行bundle
看起来成功了,但没有更新 Gemfile.lock,也没有解决问题。
最后,将所有宝石恢复到原始状态解决了问题:
gem pristine --all
我现在可以运行应用程序、rake 等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.