How can I pass a parameter for gem installation when I run bundle install?
20,299
Solution 1
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
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
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.
Author by
ben
Updated on July 08, 2022Comments
-
ben almost 2 years
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
? -
idlefingers about 13 yearsUnless it's only you working on the app and every place it may run has the same path to the postgres config, you shouldn't check this kind of thing into your scm. It is environment-specific, and might not be the same for every machine. That's why, generally, it's best to do it per-user.
-
Jirapong about 13 yearsIdlefingers, yes. that's right. so that why i gave two options. your/his choice, what best for. :-)
-
Josh about 12 yearsAwesome! Looks like this stores it in the config and will be used in the future. Thanks!