I'm attempting to build a ruby project which uses postgres running locally. Build fails on the pg gem install. I get this error
$ gem install pg -v '0.12.2'
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/path/to/.rvm/rubies/ruby-1.9.3-p545/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
so... I pass the pg_config path, and get a different error:
$ gem install pg --with-pg-config=/usr/pgsql-9.2/bin/pg_config -v '0.12.2'
ERROR: While executing gem ... (OptionParser::InvalidOption)
invalid option: --with-pg-config=/usr/pgsql-9.2/bin/pg_config
Very confused.
Make sure you have libpq-dev package installed. If you don't, install it and try installing pg again without the --with-pg-config parameter.
In regards to the --with-pg-config parameter:
When passing parameters to the gem you're installing you must use two dashes before the two dashes from the option, like so:
gem install gem-name -- --gem-option
So what you want to run in order to achieve installing pg with the --with-pg-config option is:
gem install pg -v '0.12.2' -- --with-pg-config=/usr/pgsql-9.2/bin/pg_config
EDIT
Also, one last tip, after searching a bit more about this issue I found that your ruby version and architecture might affect pg's installation, I'm quoting this link:
I was hesitant to uninstall everything so I just uninstalled Ruby and reinstalled with the option set to 64-bit only (platform: "x86_64-darwin12.2.0"). After reinstalling Ruby with this option, the PG gem installed without hitch and I am back to being happy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With