Ran into an annoying chicken/egg involving deploying to Heroku with a shared database. It seems that Heroku isn’t happy unless you have gem ‘pg’ in your Gemfile. If you are using the shared database and fail to have gem ‘pg’ in your Gemfile, you app actually deploys OK on Heroku but then generates an Application Error when you call a page. If you check the heroku logs you see something like this:
After adding gem ‘pg’ to your Gemfile and ran bundle install I was getting this error (locally):
This means that if you don’t have Postgresql locally, you can’t bundle install without it, even if you don’t want to use Postgresql locally in development. To fix this, I had to install postgresql locally, add pg to my Gemfile, rebuild the gems, and then I was successfully able re-deploy my Heroku app.
First, I ran the “One click installer” from here:
The installer had a note about how it had to change the shared memory settings on my machine (see the README file in the DMG). It created settings at /etc/sysctl.conf
After re-booting, go to the app you are trying to deploy and do this:
Finally, run bundle install again and everything should be clean. Remember, in my scenario I wasn’t really using Postgresql, I just had to have it in my Gemfile so that Heroku would allow me to deploy the app.