Mountain Lion上的pg gem'0.14.0'失败了

cas*_*yli 15 postgresql gem ruby-on-rails osx-mountain-lion

我刚从OS X Lion升级到OS X Mountain Lion.我的铁路环境大部分都保持着机智.

我必须做的唯一步骤是让事情恢复到良好状态: - 安装XCode 4.4 - 安装XCode 4.4命令行工具 - 安装gcc-4.2

一切顺利.

这是问题,当我运行bundle install时几乎所有的gem都安装正确,除了我需要的最重要的一个 - postgresql gem'pg'.

它特别适用于0.12.2以上的版本.

我正在使用ruby 1.9.3p125.

我可以成功获取0.12.2 pg宝石,以及下面的版本,但它们给我分段错误(我猜是因为我正在使用的ruby版本).

因此,这让我相信它特定于pg gem,而不是我的整体环境看到其他宝石安装正常.

我也尝试重新安装Postgresql以确保我的postgres环境没问题,并且在这方面似乎很好.

有没有人能够安装'pg'宝石版0.13.0或更高版本(更优选0.14.X)?

这是我的堆栈跟踪:

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

    /Users/caseyli/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQescapeLiteral()... yes
checking for PQescapeIdentifier()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for PQlibVersion()... yes
checking for PQping()... yes
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... no
checking for PGRES_COPY_BOTH in libpq-fe.h... no
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
creating extconf.h
creating Makefile

make
compiling pg.c
pg.c: In function ‘pg_s_library_version’:
pg.c:273: warning: implicit declaration of function ‘PQlibVersion’
pg.c: In function ‘Init_pg_ext’:
pg.c:384: error: ‘PQPING_OK’ undeclared (first use in this function)
pg.c:384: error: (Each undeclared identifier is reported only once
pg.c:384: error: for each function it appears in.)
pg.c:386: error: ‘PQPING_REJECT’ undeclared (first use in this function)
pg.c:388: error: ‘PQPING_NO_RESPONSE’ undeclared (first use in this function)
pg.c:390: error: ‘PQPING_NO_ATTEMPT’ undeclared (first use in this function)
make: *** [pg.o] Error 1


Gem files will remain installed in /Users/caseyli/.rvm/gems/ruby-1.9.3-        p125@elliottfarmequipment/gems/pg-0.14.0 for inspection.
Run Code Online (Sandbox Code Playgroud)

cas*_*yli 17

Deefour的评论得到了它!这是我安装PostgreSQL的方式.

我使用PostgreSQL一键安装程序,我猜测它没有为Mountain Lion正确设置libpq.

另一方面,Homebrew将为操作系统正确构建它.

通过自制软件安装postgres后

brew install postgresql
Run Code Online (Sandbox Code Playgroud)

我能够安装我的宝石没问题.

谢谢大家!


小智 13

问题是pg_config的位置.如果你使用一键安装程序,它在/Library/PostgreSQL/9.2/bin/pg_config中,所以这将构建你的gem就好了:

env ARCHFLAGS =" - arch x86_64"gem install pg - --with-pg-config =/Library/PostgreSQL/9.2/bin/pg_config

  • homebrew将pg_config放在`/ usr/bin/pg_config`中.我今天在这方面挣扎,所以希望这可以在将来避免一两个头痛. (2认同)

Mic*_*son 2

重新安装 ruby​​ 解决了升级到 Mountain Lion 后遇到的类似问题

rvm reinstall 1.9.3
Run Code Online (Sandbox Code Playgroud)

注意:还运行以下命令,因为默认版本似乎已重置

rvm --default 1.9.3
Run Code Online (Sandbox Code Playgroud)

作为参考,我发布了我在下面看到的错误

gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with pg=/usr/local/Cellar/postgresql/9.1.4/bin
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Run Code Online (Sandbox Code Playgroud)