When I run bundle install
, I get errors with the pg
gem (it needs to know where pg_config
is located). I can easily resolve that by installing it manually gem install ... --with-pg-config=...
, but I'm getting the same error when pushing to Heroku with git push heroku master
. I can't manually install it there, since the dyno has a read-only filesystem. Hence, is there a way to specify that I want to use --with-pg-config=...
in the Gemfile itself so that Heroku will follow the instructions on-the-fly?
You can specify the gem install configuration options in the bundle config.
Bundler retrieves its configuration from the local application (app/.bundle/config) environment variables and then user's home directory (~/.bundle/config), in that order of priority.
A very common example, the mysql gem, requires Snow Leopard users to pass configuration flags to gem install to specify where to find the mysql_config executable.
gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Since the specific location of that executable can change from machine to machine, you can specify these flags on a per-machine basis.
bundle config build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
After running this command, every time bundler needs to install the mysql gem, it will pass along the flags you specified.
Visit bundle-config for more info.