Heroku on Windows

Next month, 80 people with laptops are going to show up and expect me to teach them something about Rails. I want them to see the app they’re writing on the web, but I only have six hours in the workshop (including lunch!) and deployment could easily take that much time by itself. Apache and nginx and Passenger and Capistrano and memcached and…yeah. These are beginners.

So I’m super stoked about Heroku, who’s come to put the easy into Rails deployment. Register, install the gem, and deploying – with a real URL and everything – is as easy as git push heroku.

Sounds great! But it turns out that using the Heroku client on Windows is slightly problematic. With the standard Rails crowd, I wouldn’t worry, but it looks like about half the attendees will bring some flavor of Windows. So my choices were either make it work on Windows, or scrap the idea of, you know, putting apps on the internet.

So I fixed it. It turned out to be relatively straightforward. The shell method, which takes a command and returns its output, was doing this:

`cd '#{Dir.pwd}' && #{cmd}`

Windows thinks ' is a perfectly good character for directory names, so all calls to shell in Windows generated this error:

The filename, directory name, or volume label syntax is incorrect.

How helpful. In any case, it won’t be doing that anymore. My changes are up on github, and I’ve sent the official heroku client a pull request.

The client still has two spec failures on Windows (running within MsysGit’s Git Bash) that are unrelated to this change, and actually represent fairly significant cross-platform challenges.


'Heroku::Command::Auth sets ~/.heroku/credentials to be readable only by the user' FAILED
expected: 16832,
got: 16877 (using ==)
./spec/commands/auth_spec.rb:49:

The client fails to chmod your credentials file to user-only read, because File.chmod doesn’t do anything. As I’m sure you’re aware, there are significant differences between POSIX-style file permissions and Windows ACLs (access control lists).

So your credentials file, which has your Heroku username and password in plaintext, may be readable by other users. This generally isn’t as much of an issue on Windows as it is on *nix but it’s something to be aware of. You may want to adjust the ACLs by hand if you’re on a multi-user system.


NotImplementedError in 'Heroku::Command::App Git Integration before(:all)'
fork() function is unimplemented on this machine
./spec/commands/app_spec.rb:103:

Yep, as the error message suggests, Kernel::fork is not implemented in Windows Ruby. The Heroku client does not use fork – it’s in one of the gems, Session, which is used by Rush, which the Heroku test framework uses to create a sandbox git installation.

I haven’t looked too extensively at this one, but it might be possible to rewrite it to work on Windows. Rush does have some code specific to Windows, and there are alternate ways to sandbox the git install as well.

So given that neither of these failures affects the functioning of the client, I’m confident it’ll be usable on everyone’s laptop. I’m also super excited that one of the Heroku engineers, Pedro, has volunteered to help out with installation at the workshop!

We’re still looking for other volunteers – if you’re interested please email ruby workshop at gmail dot com.

6 comments to Heroku on Windows