How can I pass a parameter for gem installation when I run bundle install?
Ruby on-RailsRuby on-Rails-3GemBundlerRuby on-Rails Problem Overview
I added the pg gem to my gemfile
gem 'pg'
When I run bundle install
, I get this error:
Installing pg (0.10.1) with native extensions /Users/ben/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Users/benhartney/.rvm/rubies/ruby-1.9.2-p0/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.
It seems I need to pass in this config parameter
--with-pg-config=/path/to/pg_config
How can I do this when I use bundle install
?
Ruby on-Rails Solutions
Solution 1 - Ruby on-Rails
You need to set a build config option like so:
bundle config build.pg --with-pg-config=/path/to/pg_config
More info can be found in the bundle config man page
Solution 2 - Ruby on-Rails
Run 'bundle config' before 'bundle install' to set the parameters, i.e.:
bundle config build.pg --with-pg-config=/path/to/pg_config
bundle install
Solution 3 - Ruby on-Rails
with Rails3 and PostgreSQL. I do like this
>rails new test_app -d postgreSQL
>cd test_app
>mkdir .bundle
>echo "BUNDLE_BUILD__PG: --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config" > .bundle/config
>bundle install
so you can keep config in source control.
for user's profile
bundle config build.pg --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config
this will create ~/.bundle/config file.
Solution 4 - Ruby on-Rails
If you're using Ruby 2.x and up, then thrift 0.9.0 can't build with it. see https://issues.apache.org/jira/browse/THRIFT-2219. Thrift 0.9.2 is fixed.
Try installing:
gem install rbhive -v 1.0.3.pre