未加载库:libpq.5.dylib

时间:2012-02-07 19:35:10

标签: ruby-on-rails postgresql libpq

我有运行Ruby 1.9.2,Rails 3和postgreSQL 8.3的应用程序。它最初设置并使用postgreSQL 9.1,但我卸载了9.1并安装并更改为8.3以确保Heroku共享数据库设置的兼容性。它运行正常,但现在不是

现在,在处理这个应用程序时,当我运行数据库升级时,我收到此错误:

dlopen(/Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib
  Referenced from: /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle
  Reason: no suitable image found.  Did find:
    /usr/lib/libpq.5.dylib: no matching architecture in universal wrapper - /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle

当我尝试运行服务器时,我收到以下错误消息:

/Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg.rb:4:in `require': dlopen(/Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib (LoadError)
  Referenced from: /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle
  Reason: no suitable image found.  Did find:
    /usr/lib/libpq.5.dylib: no matching architecture in universal wrapper - /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg.rb:4:in `<top (required)>'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
    from /Users/michaeljmccoy/www/mikemccoy/config/application.rb:7:in `<top (required)>'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:53:in `require'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:50:in `tap'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我知道它们是非常相似的错误,可能与丢失的路径有关。但是,当我将路径添加到.profile文件并重新启动终端窗口时,我会收到相同的错误。

2 个答案:

答案 0 :(得分:35)

您可能需要删除并重新安装pg gem,因此它是根据Postgres的正确版本编译的。

答案 1 :(得分:4)

对于看到此错误并运行PostgresApp的任何人,这是一个已在9.2.4.3版本中修复的已知问题:

讨论:https://github.com/PostgresApp/PostgresApp/issues/109

安装程序:https://github.com/PostgresApp/PostgresApp/releases/tag/9.2.4.3

当然,你可以抓住最新版本(http://postgresapp.com/)。这两个版本让我重新启动并运行Rails 3.2.14和Ruby 2.0.0。但请注意,当我安装9.2.4.3时,我的数据库仍然在psql中列出,但是当我安装9.3.0(目前的当前版本)时,我的数据库不再列出。