【问题标题】:rails - postgres error: Reason: Incompatible library version: libpq.5.dylib requires version 1.0.0 or later,rails - postgres 错误:原因:库版本不兼容:libpq.5.dylib 需要 1.0.0 或更高版本,
【发布时间】:2012-06-23 01:23:06
【问题描述】:

我的 Mac (10.6.8) 上的 Ruby (1.9.3)、Rails 和 Postgres (9.0.8) 设置卡住了。 每次我运行rails console 时都会出现以下错误:

/Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/pg-0.13.2/lib/pg.rb:4:in `require': dlopen(/Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/pg-0.13.2/lib/pg_ext.bundle, 9): Library not loaded: @loader_path/../lib/libssl.dylib (LoadError)
  Referenced from: /usr/lib/libpq.5.dylib
  Reason: Incompatible library version: libpq.5.dylib requires version 1.0.0 or later, but libssl.0.9.8.dylib provides version 0.9.8 - /Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/pg-0.13.2/lib/pg_ext.bundle  
    from /Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/pg-0.13.2/lib/pg.rb:4:in `<top (required)>'
    from /Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:in `require'
    from /Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:in `each'
    from /Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `each'
    from /Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `require'
    from /Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/bundler-1.1.4/lib/bundler.rb:119:in `require'
    from /Users/dc/Documents/Aptana Studio 3 Workspace/http/config/application.rb:7:in `<top (required)>'
    from /Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/railties-3.2.6/lib/rails/commands.rb:39:in `require'
    from /Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/railties-3.2.6/lib/rails/commands.rb:39:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我真的不知道如何解决这个问题。我已经尝试安装不同的 Postgres 版本,但仍然出现同样的错误。

【问题讨论】:

  • 我正在努力解决同样的问题。如果这有帮助....

标签: ruby-on-rails ruby macos postgresql osx-snow-leopard


【解决方案1】:

在这里找到了一个对我有用的解决方案: https://github.com/PostgresApp/PostgresApp/issues/109

【讨论】:

  • 能否提供解决方案的摘要?这将使您的答案更容易获得,而且如果链接页面消失,它仍将保留价值。
  • export DYLD_FALLBACK_LIBRARY_PATH=/Applications/Postgres.app/Contents/MacOS/lib:$DYLD_LIBRARY_PATH 为我工作
【解决方案2】:

在一个项目中,这个解决方案(“gem install & uninstall pg”)很好。

但在另一个项目中,使用相同的 rails 和 Postgres 版本,我必须在 gemfile 中明确使用版本才能使其工作:

  gem 'pg', '0.14.1'

【讨论】:

    【解决方案3】:

    安装新的 PostgreSQL 版本(我用的是自制软件)

    brew install postgres
    

    然后重新安装gem pg:

    gem uninstall pg
    gem install pg
    

    希望对你有帮助。

    【讨论】:

    • 没有“postgre”之类的东西,brew install postgre 只会产生错误。我假设您的意思是“postgres”或“PostgreSQL”?另外,原发帖人说他们已经尝试过新的Pg版本了。
    【解决方案4】:

    如上对文件进行符号链接对我不起作用。 pg 将始终查看 libssl-0.9.8.dylib。

    这个问题似乎包含正确答案:gem install pg --with-pg-config works, bundle fails

    归结为

    bundle config build.pg --with-pg-config=/Library/PostgreSQL/9.1/bin/pg_config

    (或您所针对的任何 pg)

    接着是gem uninstall pg,然后是bundle install

    【讨论】:

      【解决方案5】:

      我也遇到了这个问题,但能够按照python pip install psycopg2 install error 上的说明进行修复。

      首先,确保您已安装 most recent version of OpenSSL:

      MacBook Pro:~> openssl version -a
      OpenSSL 1.0.0c 2 Dec 2010
      built on: Mon Jan  3 17:26:21 PST 2011
      platform: darwin64-x86_64-cc
      options:  bn(64,64) rc4(ptr,char) des(idx,cisc,16,int) idea(int) blowfish(idx) 
      compiler: /usr/bin/gcc-4.2 -fPIC -fno-common -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall
      OPENSSLDIR: "/opt/local/etc/openssl"
      

      ...并注意 OPENSSLDIR。在我的系统上,它位于 /opt/local/,因为我是通过 MacPorts 安装它的。我只需要更新 /usr/lib/ 中 libssl.dylib 和 libcrypto.dylib 的符号链接,以便它们指向 /opt/local/lib 中的正确版本,而不是 usr/lib 中的旧版本:

      MacBook Pro:~> ls -la /usr/lib/libssl.dylib 
      lrwxr-xr-x  1 root  wheel  33 Aug 17 12:25 /usr/lib/libssl.dylib -> /opt/local/lib/libssl.1.0.0.dylib
      MacBook Pro:~> ls -la /usr/lib/libcrypto.dylib 
      lrwxr-xr-x  1 root  wheel  36 Aug 17 12:28 /usr/lib/libcrypto.dylib -> /opt/local/lib/libcrypto.1.0.0.dylib
      

      您可以使用ln 命令创建链接:

      sudo ln -s /path/to/postgres/install/lib/libcrypto.dylib /usr/lib/libcrypto.dylib
      sudo ln -s /path/to/postgres/install/lib/libssl.dylib /usr/lib/libssl.dylib
      

      【讨论】:

      • 很好,我终于让它工作了。我按照描述设置符号链接并设置捆绑配置...
      猜你喜欢
      • 2013-09-20
      • 2014-06-04
      • 1970-01-01
      • 2013-10-01
      • 2017-05-21
      • 1970-01-01
      • 2015-10-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多