Heroku looks to be a very promising way of writing Rails applications with easy deployment, source control, and hosting all built-in.
Step 1: Install Cygwin
I can’t stress enough how awesome this tool is. it gives you a unix-style shell that supports a number of things, namely Git. You can’t run Git on windows without msys-git or similar and it is required for Heroku. (Git is the deployment mechanism for packaging up your changes and sending them to Heroku).
When you install cygwin, make sure to expand the packages and install at least the following:
- ruby <—some say this is buggy, but it seems to work for me
Wait for it to download and install those packages. There might be others, but those are the major ones installed on my machine. If you already have cygwin installed, you can run the setup.exe file again and select the packages you’re missing.
Step 2: Install Rubygems
Note that this is required even if you already have the one-click ruby installer on windows. Steven Harman wrote about how to do this in cygwin:
- Download the RubyGems tarball from Ruby Forge
- Unpack the tarball
- In a bash terminal, navigate to the unpacked directory
- Run the following command:
<em>ruby setup.rb install</em>
- Update RubyGems by running the following:
<em>gem update --system</em>
Note: You may need to run the updated command twice if you have any previously installed gems.
Note, if you try to run some ruby files and you get a “could not load rubygems” error, you may need to unset the RUBYOPT environment variable. The windows version might be conflicting with the cygwin version.
Step 3: Install sqlite3-ruby gem
The sqlite3-ruby gem is actually a CGem (not ruby) so it needs a windows binary. Unfortunately, there isn’t a windows version yet, so you need to back up to the latest one that does, which is 1.2.3 as of this post.
If this fails with an error saying “looking for sqlite.h…no” then you probably haven’t installed the libsqlite3_devel package in cygwin. This tripped me up.
Step 4: Install json gem
Again, the latest version of this gem doesn’t work yet with Windows, so you have to request version 1.1.1.
Step 5: Install Heroku gem
Step 6: Create an SSH key file
In order to communicate securely with heroku, you need to create an SSH key file.
1 2 3 4
This should create a public & private key file. Heroku will look for this.
Now we can follow the standard heroku instructions, which are pretty simple. Here’s how you’d create a sample rails app, initialize git, add files, and create the app on heroku. Finally we’ll push the code & you can see it running online.
1 2 3 4 5 6 7
You’ll be given a URL when you create the app on heroku, so after you push you can visit http://your-app-name.heroku.com to see it live!
Hope this helps someone else get started faster than me!