An error occurred while installing pg (0.17.1), an

2019-01-08 06:32发布

I just installed Rails 4.0.2 and when creating a new app, in the bundle stage I get:

Installing pg (0.17.1) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/Dee/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

How do I fix this?

13条回答
Lonely孤独者°
2楼-- · 2019-01-08 06:59

If gem install pg fails, try the following command:

env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config

... from the PostgreSQL.app Documentation

查看更多
登录 后发表回答