升级后得到 ruby:找不到符号:__ZN6libdap5ErrorD1Ev

Got after upgrading ruby: Symbol not found: __ZN6libdap5ErrorD1Ev

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

我已经尝试将我的 ruby 版本从 2.5 升级到 2.7.4

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

但现在每当我启动 rails crails 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,我会遇到同样的问题

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

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

因此,通常首先尝试修复此问题以重新安装受影响的 gem。如果您使用捆绑器,您可以通过 运行ning

重新安装项目的所有 gems
bundle pristine

这应该确保您的捆绑器管理的 gem 都使用最新版本的库。有关此命令的详细信息,请参阅 the documentation of bundle pristine