[英]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.