繁体   English   中英

pg宝石'0.14.0'在Mountain Lion上失败

[英]pg gem '0.14.0' on Mountain Lion fails

我刚刚从OS X Lion升级到OS X Mountain Lion。 我的rails环境大部分保持不变。

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

所以一切顺利。

这就是问题所在,当我运行捆绑安装时,几乎所有我的gem都正确安装,除了我需要的最重要的之一-postgresql gem'pg'。

特别是对于高于0.12.2的版本,它将失败。

我正在使用ruby 1.9.3p125。

我可以成功获取0.12.2 pg的宝石和以下版本,但是它们给我带来分割错误(我猜是因为我使用的红宝石版本)。

因此,这使我相信它是特定于pg gem的,而不是我的整体环境看到其他gem可以正常安装。

我还尝试重新安装Postgresql,以确保我的postgres环境正常并且在那方面看起来不错。

是否有人能够安装“ pg” gem版本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.

迪福的评论得到了! 这是我安装PostgreSQL的方式。

我使用的是PostgreSQL一键式安装程序,我猜它无法为Mountain Lion正确设置libpq。

另一方面,自制软件将为操作系统正确构建它。

通过自制软件安装postgres之后

brew install postgresql

我能够安装我的宝石没有问题。

谢谢大家!

问题是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

我有完全相同的问题; 与您发布的堆栈跟踪相同。

带有自制软件的MRI 1.9.3-p286 / OS X 10.8.2 / Postgres 9.0.4。

我通过简单地解决它:

$ brew update
$ brew upgrade postgresql
$ bundle

希望它对其他人有用。

重新安装红宝石修复了我升级到Mountain Lion后遇到的类似问题

rvm reinstall 1.9.3

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

rvm --default 1.9.3

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

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 ***

Mac随附了过时的预建PostgreSQL客户端安装,并且随附的pg_config文件与任何新的PostgreSQL服务器和客户端安装冲突。

使用完全限定的文件名pg_config安装ruby gem会覆盖pg_config的默认已知位置,并且安装成功。

通过EnterpriseDB一键安装程序pg_config的当前位置:/ Library / PostgreSQL / bin / pg_config

这个命令终于对我有用。

CrashMX2$ gem install pg -- --with-pg-config=/Library/PostgreSQL/bin/pg_config

我有同样的问题,但是用自制软件重新安装postgresql并不能解决问题。 但是,此命令为我做到了:

sudo env ARCHFLAGS="-arch x86_64" gem install pg

我可以通过从Heroku安装Postgres.app并删除我现有的postgresql安装来使其工作。 您可以在此处下载该应用:

http://postgresapp.com/

brew remove postgresql

bundle install

如果您不使用brew,请点击这里,从Postgres.app获取更多卸载文档的链接。

http://postgresapp.com/documentation#toc_16

我只是通过这张车票开始运行的:

运行捆绑安装时如何为gem安装传递参数?

bundle config build.pg --with-pg-config=/path/to/pg_config
bundle install

就像Matt,Ranjan和Peter Mellett都说过的那样,您必须找到正确的pg_config位置,Mountain Lion所处的位置似乎与rubygems不太匹配,所以如果您发现旧版本像

/Library/PostgreSQL/bin/pg_config

那么您可以在安装之前在bundle config中进行设置。

我的情况是从Lion升级到Mountain Lion。

Homebrew在/usr/local/bin/pg_ctl安装了pg_ctl ,所以对我来说命令是:

env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/bin/pg_ctl

对于使用Kubuntu 13.04并使用一键式工具安装pg的用户,pg config位于其他文件夹中,因此命令:

gem install pg -- --with-pg-config=/opt/PostgreSQL/9.3/bin/pg_config

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM