2012-06-20 75 views
8

我坚持使用Ruby(1.9.3),Rails和Postgres(9.0.8)的设置我的Mac(10.6.8)。 每次当我运行rails console我得到以下错误:rails-postgres错误:原因:不兼容的库版本:libpq.5.dylib需要版本1.0.0或更高版本,

/Users/dc/.rvm/gems/[email protected]/gems/pg-0.13.2/lib/pg.rb:4:in `require': dlopen(/Users/dc/.rvm/gems/[email protected]/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/[email protected]/gems/pg-0.13.2/lib/pg_ext.bundle 
    from /Users/dc/.rvm/gems/[email protected]/gems/pg-0.13.2/lib/pg.rb:4:in `<top (required)>' 
    from /Users/dc/.rvm/gems/[email protected]/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:in `require' 
    from /Users/dc/.rvm/gems/[email protected]/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:in `block (2 levels) in require' 
    from /Users/dc/.rvm/gems/[email protected]/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:in `each' 
    from /Users/dc/.rvm/gems/[email protected]/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:in `block in require' 
    from /Users/dc/.rvm/gems/[email protected]/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `each' 
    from /Users/dc/.rvm/gems/[email protected]/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `require' 
    from /Users/dc/.rvm/gems/[email protected]/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/[email protected]/gems/railties-3.2.6/lib/rails/commands.rb:39:in `require' 
    from /Users/dc/.rvm/gems/[email protected]/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版本,我仍然得到相同的错误。

+0

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

回答

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 
+1

不错,我终于得到它的工作。我按照描述设置符号链接并设置包配置... – dc10

+0

太棒了!很高兴听到这个工作。 – MothOnMars

0

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

brew install postgres 

然后重新安装宝石PG:

gem uninstall pg 
gem install pg 

希望它有帮助。

+1

没有“postgre”这样的东西,并且'brew install postgre'只会产生一个错误。我假设你的意思是“postgres”或“PostgreSQL”?另外,原始海报表示他们已经尝试过新的Pg版本。 –

5

如上所述对文件进行符号链接对我无效。 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

(或任何皮克你的目标),其次是gem uninstall pg

然后bundle install

+1

这对我有效:) –

+0

对我而言,谢谢! –

1

在一个项目中,这个解决方案(“宝石安装&卸载pg“)很好。

但在另一个项目中,使用相同的轨道和Postgres版本,我必须明确的使用版本中的Gemfile,使其工作:

gem 'pg', '0.14.1' 
0

在这里找到一个解决方案,为我工作: https://github.com/PostgresApp/PostgresApp/issues/109

+0

您能否包括解决方案的摘要?这将使您的答案更易于访问,而且如果链接页面消失,它仍然会保留价值。 –

+0

'export DYLD_FALLBACK_LIBRARY_PATH =/Applications/Postgres.app/Contents/MacOS/lib:$ DYLD_LIBRARY_PATH'适用于我 –

相关问题