pg gem '0.14.0' on Mountain Lion fails

我与影子孤独终老i 提交于 2019-11-28 10:52:21

Deefour's comment got it! It was the way I installed PostgreSQL.

I use the PostgreSQL one-click installer which I'm guessing doesn't set up the libpq up properly for Mountain Lion.

Homebrew on the otherhand will build it properly for the OS.

After installing postgres through homebrew

brew install postgresql

I was able to install my gem no problem.

Thanks everybody!

The issue is the location of pg_config. If you use the one-click installer, it is in /Library/PostgreSQL/9.2/bin/pg_config, so this will build your gem just fine:

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

I had the exact same issue; same stack trace as you've posted.

MRI 1.9.3-p286 / OS X 10.8.2 / Postgres 9.0.4 with homebrew.

I solved it by simply doing:

$ brew update
$ brew upgrade postgresql
$ bundle

Hope it works for someone else.

Reinstalling ruby fixed a similar issue I was having after upgrading to Mountain Lion

rvm reinstall 1.9.3

Note: also run the following as it seems the default version resets

rvm --default 1.9.3

For reference I posted the error I was seeing below

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 comes with an outdated prebuilt PostgreSQL client installation and pg_config file that comes with it conflicts with any new PostgreSQL server & client installations.

Installing ruby gem with a fully qualified file name of pg_config overrides default known location of pg_config and installation succeeds.

Current location of pg_config by one click installer by EnterpriseDB: /Library/PostgreSQL/bin/pg_config

This command finally worked for me.

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

I have had the same problem but reinstalling postgresql with homebrew did not solve it. However, this command did it for me:

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

I was able to get it to work by installing the Postgres.app from Heroku and removing my existing postgresql installation. You can download the app here:

http://postgresapp.com/

brew remove postgresql

bundle install

If you didn't use brew, here's a link to more uninstall docs from Postgres.app

http://postgresapp.com/documentation#toc_16

aferris

I just got mine up and running via this ticket:

How can I pass a parameter for gem installation when I run bundle install?

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

Like Matt, Ranjan, and Peter Mellett all say, you have to get the right pg_config location, and Mountain Lion comes with a different location that doesn't seem to play well with rubygems, so if you find your old version like

/Library/PostgreSQL/bin/pg_config

then you can set that in the bundle config before installing.

My situation was upgrading from Lion to Mountain Lion.

Homebrew installed pg_ctl in /usr/local/bin/pg_ctl, so the command for me was:

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

Fro those, who are using Kubuntu 13.04 and installed pg with one click tool, pg config is in other folder, so command:

gem install pg -- --with-pg-config=/opt/PostgreSQL/9.3/bin/pg_config
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!