Rose Rose - 6 months ago 25
Ruby Question

bundle install fails without postgresql

When I run

bundle install
I get this error:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /usr/local/lib/ruby/gems/2.3.0/gems/pg-0.18.4/ext
/usr/local/opt/ruby/bin/ruby -r ./siteconf20160601-64492-1nt86nq.rb 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.

... [a long list of config options] ...

An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.


Then when I try
gem install pg -v '0.18.4'
like it suggests I get the same error without the suggestion to run the command I just tried. I'm not running postgres and have never installed it, so I'm a bit confused about why this is happening.

There is a similar question here, but again, I don't have postgresql. Do I need it? Question: gem install pg -v 0.12.2 error on mac

Any help is appreciated. Thank you.

Answer

Yes, in order to install the pg gem you must have postgresql installed. You can find downloads and install instruction on their website.

Specifically it says you need a pg_config file, which I guess woukd be created upon installation.