pg 0.14.1:dyld:延迟符号绑定失败:找不到符号:_PQconnectdb
在 El Capitan 上运行 postgresql 9.4.5 和 pg 0.14.1,在执行第一个查询时遇到以下错误,然后从 Rails 控制台退出:
Running postgresql 9.4.5 and pg 0.14.1 on El Capitan, and experiencing the following error followed by an exit from the Rails console when performing the first query:
dyld:懒惰的符号绑定失败:找不到符号:_PQconnectdb引用自:/Users/christian/Documents/Development/onelogin.com/vendor/bundle/gems/pg-0.14.1/lib/pg_ext.bundle预期在:平面命名空间
dyld: lazy symbol binding failed: Symbol not found: _PQconnectdb Referenced from: /Users/christian/Documents/Development/onelogin.com/vendor/bundle/gems/pg-0.14.1/lib/pg_ext.bundle Expected in: flat namespace
dyld:找不到符号:_PQconnectdb引用自:/Users/christian/Documents/Development/onelogin.com/vendor/bundle/gems/pg-0.14.1/lib/pg_ext.bundle预期在:平面命名空间
dyld: Symbol not found: _PQconnectdb Referenced from: /Users/christian/Documents/Development/onelogin.com/vendor/bundle/gems/pg-0.14.1/lib/pg_ext.bundle Expected in: flat namespace
跟踪/BPT陷阱:5
有什么想法吗?
这意味着 gem 编译所针对的 libpq
库丢失或由于某种原因不再可加载.通常,您需要在操作系统升级后或安装新版本的 XCode 命令行工具后重新安装 PostgreSQL.
This means that the libpq
library the gem was compiled against is missing or is no longer loadable for some reason. Oftentimes you'll need to reinstall PostgreSQL after an OS upgrade, or after installing a new version of the XCode command line tools.
您可以像这样查看 gem 尝试加载的库(无论如何在 OSX 上):
You can look at the library the gem is trying to load like this (on OSX anyway):
file $(otool -L/Users/christian/Documents/Development/onelogin.com/vendor/bundle/gems/pg-0.14.1/lib/pg_ext.bundle | grep libpq | cut -f1 -d' ')
它应该看起来像这样:
/usr/local/lib/libpq.5.dylib: Mach-O 64 位动态链接共享库 x86_64
我的 PostgreSQL 是通过 Homebrew 安装的,所以你的路径可能不同,但它至少应该显示一个共享库.如果看起来没问题,请在评论中发表评论,我会尽力提供进一步帮助.
My PostgreSQL is installed via Homebrew, so your path might be different, but it should at least show a shared library. If it looks okay, post what it says in a comment and I'll try to help further.