суббота, 21 января 2012 г.

pg gem installation

If you try bundle install after adding gem 'pg' in your Gemfile you'll get:
$ bundle install
Installing pg (0.12.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/local/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 ***
...
An error occured while installing pg (0.12.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.12.2'` succeeds before bundling.


I need pg gem for heroku deployment, but don't want to have postgres on development side.
There are 2 solutions:
1) It won't install gems from production group. Obviously, you should place pg gem in it.
$ bundle install --without production

2) It will install gems from production group only on corresponding environment.
Open config/application.rb
Do comment: Bundler.require(*Rails.groups(:assets => %w(development test)))
Uncomment: Bundler.require(:default, :assets, Rails.env)

Voila

1 комментарий: