Enough local development. It’s time to push something live. Based on experiences with a couple of other lightweight apps, I’m looking to use Heroku. So what does that entail?
To start, I had to get git set up in my project directory and commit the files. Heroku has some pretty straightforward guidance on this. However, before creating a “Heroku Remote”, as demonstrated using the command: heroku create –stack cedar, I wanted to understand what else I might need to change. The “–stack cedar” parameters gave me pause, so I went back to the support section on Heroku to look at the getting started content. There, I discovered that I needed to make two changes.
The first change would be to get on Ruby 1.9.2. Not knowing what version I was running, I typed ruby -v and found that I was on 1.8.7 (which happens to be what’s shipped by default on my MacBook Air. After a google search, I saw some advice to use rvm to manage my versions of Ruby. Ok, followed the commands and installed 1.9.2. So far, so good.
Next, I noticed that Heroku uses PostgreSQL. I’ve been using Mysql to develop locally and was hoping I could just use that in production, but looks like I have to switch. Ok, I use the One Click installer found here, and add gem ‘pg’ to my Gemfile. Now, I just need to run bundle install and expect to be all set. Um, not so fast…
Building native extensions. This could take a while…
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
checking for pg_config… no
No pg_config… trying anyway. If building fails, please try again with
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.
Provided configuration options:
Gem files will remain installed in /Users/kmr2/.rvm/gems/ruby-1.9.2-p318/gems/pg-0.13.2 for inspection.
Results logged to /Users/kmr2/.rvm/gems/ruby-1.9.2-p318/gems/pg-0.13.2/ext/gem_make.out
Well, this looks like fun. After much searching and trial and error, the answer that worked was in a StackOverflow post on this issue. But it wasn’t one of the top answers – it was this one:
PATH=$PATH:/Library/PostgreSQL/9.1/bin sudo gem install pg
Ok, enough for this post. Now I’m going to try switching my dev environment over to PostgreSQL (I don’t want to be using different databases in development than production – no interest in trying to debug any issues that might crop up over time:)