首页 > 解决方案 > 升级 ruby​​ 后得到:找不到符号:__ZN6libdap5ErrorD1Ev

问题描述

我试图理解错误已经好几个小时了,但我不明白。

我试图将我的 ruby​​ 版本从 2.5 升级到 2.7.4

我首先更新rbenvbrew然后安装 2.7.4 版本并使用rbenv rehash

但是现在每当我启动rails cor时rails s,我都会遇到以下错误:

Loading development environment variables
 - load /Users/myself/Work/my-app/.env
/Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': dlopen(/Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/bundler/gems/gdal-ruby-1820e1643725/lib/gdal-ruby/gdal.bundle, 9): Symbol not found: __ZN6libdap5ErrorD1Ev
  Referenced from: /usr/local/opt/gdal/lib/libgdal.28.dylib
  Expected in: /usr/local/opt/libdap/lib/libdap.27.dylib
 in /usr/local/opt/gdal/lib/libgdal.28.dylib - /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/bundler/gems/gdal-ruby-1820e1643725/lib/gdal-ruby/gdal.bundle (LoadError)
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/bundler/gems/gdal-ruby-1820e1643725/lib/gdal.rb:2:in `<main>'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/runtime.rb:74:in `block (2 levels) in require'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/runtime.rb:69:in `each'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/runtime.rb:69:in `block in require'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler.rb:174:in `require'
    from /Users/myself/Work/my-app/config/application.rb:9:in `<top (required)>'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `require'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `preload'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
    from /Users/myself/.rbenv/versions/2.7.4/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'

我试图从 brew 重新安装 rbenv 但没有用,我花了几个小时试图理解这个错误的含义,但作为一个初学者我不明白。

我应该寻找什么?

编辑:这不是来自 bootsnap,因为如果我删除 bootsnap,我也会遇到同样的问题

标签: ruby-on-railsrubyrbenv

解决方案


brew upgrade当您安装其他软件时,您现有 gem 的某些依赖项可能已在(隐式)运行期间更新。

在安装使用库依赖项的 gem 时(例如libgdal在您的情况下),如果底层库以不兼容的方式更改,则有时可能需要重新编译这些 gem。

因此,第一次尝试解决此问题以重新安装受影响的 gem。如果您使用捆绑器,您可以通过运行重新安装项目的所有 gem

bundle pristine

这应该确保您的捆绑程序管理的 gem 都使用最新版本的库。有关此命令在后台执行的详细信息,请参阅文档。bundle pristine


推荐阅读