惰性符号绑定失败

lazy symbol binding failed

使用 OS X Yosemite,对于现有的 Rails 项目,我安装了 ruby 版本 2.3.0(使用 rbenv),安装了捆绑器,捆绑和重复。现在,当我尝试使用 bundle exec rails 启动 rails 服务器时,出现以下错误。

我不完全确定在安装 ruby 2.3.0 后发生了什么,因为这实际上发生在一段时间之前,并且由于我无法及时让它工作,我换回了一个较旧的 ruby 目前的版本。从那时起,我一直在寻找解决方案已有一段时间了。此处和其他站点对类似问题的解决方案并未解决此问题。也许最明显的解决方案,如下所述,运行 gem pristine --all 没有解决问题。真心希望大家多多指教,万分感谢!

-> bundle exec rails s
Ignoring binding_of_caller-0.7.2 because its extensions are not built.  Try: gem pristine binding_of_caller --version 0.7.2
Ignoring byebug-9.0.5 because its extensions are not built.  Try: gem pristine byebug --version 9.0.5
Ignoring debug_inspector-0.0.2 because its extensions are not built.  Try: gem pristine debug_inspector --version 0.0.2
Ignoring pg-0.18.4 because its extensions are not built.  Try: gem pristine pg --version 0.18.4
Ignoring puma-3.4.0 because its extensions are not built.  Try: gem pristine puma --version 3.4.0
Ignoring sqlite3-1.3.11 because its extensions are not built.  Try: gem pristine sqlite3 --version 1.3.11
Ignoring websocket-driver-0.6.4 because its extensions are not built.  Try: gem pristine websocket-driver --version 0.6.4
dyld: lazy symbol binding failed: Symbol not found: _rb_data_object_alloc
  Referenced from: /Users/nandersen/Projects/the-lunch/vendor/bundle/gems/pg-0.18.4/lib/pg_ext.bundle
  Expected in: flat namespace

dyld: Symbol not found: _rb_data_object_alloc
  Referenced from: /Users/nandersen/Projects/the-lunch/vendor/bundle/gems/pg-0.18.4/lib/pg_ext.bundle
  Expected in: flat namespace

更新

这是对答案建议的更新。以下错误对于所有提到的宝石都是相同的。

gem pristine binding_of_caller --version 0.7.2
ERROR:  While executing gem ... (Gem::Exception)
    Failed to find gems ["binding_of_caller"] = 0.7.2

尝试按照错误消息中的提示进行操作:

gem pristine binding_of_caller --version 0.7.2
gem pristine byebug --version 9.0.5
gem pristine debug_inspector --version 0.0.2
gem pristine pg --version 0.18.4
gem pristine puma --version 3.4.0
gem pristine sqlite3 --version 1.3.11
gem pristine websocket-driver --version 0.6.4

尝试 Install Postgresql 使用 libpq-dev lib

您似乎没有 psql 驱动程序

调用者绑定的文档说它有效直到ruby 2.1

Only works in MRI Ruby 1.9.2, 1.9.3, 2.0, 2.1 and RBX (Rubinius)

参考: https://github.com/banister/binding_of_caller#user-content-binding_of_caller

因为我已经尝试了很多来消除这个错误,所以我无法确切地说出最终解决了它的原因 - 但在找到解决方案的过程中我发现我可能已经通过 github 安装了 rbenv拉以及自制软件。假设这可能导致未安装的 gem(在特定 ruby 版本下)被声明为已安装,这似乎是一个可能的解释。在 运行 rm -rf ~/.rbenv 之后,在安装 brew 的 rbenv 版本的同时,在重新安装 gems 时清除了 "ignoring ... because its native...." 提示。

pg 应用程序的安装问题已通过重置正确的配置路径解决:

bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config

然后是运行bundle