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?
app root:
NOTE: replace the version number in step 3 if needed.
Looks like you do not have PostgreSQL installed. The
pg
gem requires some headers from PostgreSQL to compile native extension.I'm on a Mac running Mavericks. My solution was to install Postgres.
And then in terminal install using homebrew with the configuration:
Note: This answer has been edited to use the
latest
symlink that is currently included in shipping versions of the Postgres app.Previous versions suggested:
It works for me
]2
The way I managed to get past that error was:
This did it for me.
I needed to use sudo