Belighted

Platypus - Belighted developers' playground

Platypus

Belighted developers' playground

Ruby 2.0 and Rails 4 on Heroku

So you’re living on the edge. Ruby 2.0 is in RC, and you want it! Rails 4 is still in beta, but you take it directly from the git. You should not have to write your brand-new app in soon to be ancient language and framework versions.

We are right there with you! In this post, I will cover how you can deploy with these dependencies on Heroku. Also, expect a post about forking your dependencies and adapting them to Rails 4 pretty soon!

Ruby

Although it is not mentionned in the offical docs yet, Heroku already supports ruby-2.0.0.rc1. To tell it to use this version, just add this line at the top of your Gemfile:

Gemfile
1
ruby '2.0.0'

Rails

Rails is just a gem dependency, so everything should work out-of-the-box, right?

Well, almost. I had trouble running the server, because Heroku launches bundle exec rails server by default, and with the current master, this outputs the help for rails new for some reason.

Thankfully, you can use script/rails, so all you need is a Procfile:

Procfile
1
2
web: script/rails server -p $PORT
console: script/rails console

This will fix both the default server and the console, so everything should work fine. I also tried using thin, but then things got a little weird:

1
2
ruby: symbol lookup error: /app/vendor/bundle/ruby/2.0.0/gems/eventmachine-1.0.0/lib/rubyeventmachine.so: undefined symbol: rb_enable_interrupt
Process exited with status 127

I guess eventmachine is not fully 2.0 compatible yet…

Unicorn, however, worked fine. I used an old config file, too, so you can probably thrust any tutorial out there if it worked with Ruby 1.9 and Rails 3.

And that’s all folks! Who said living on the edge was hard? Feel free to comment if you tried another server (Puma anyone?), and tell us what did and did not work for you.

Comments

Comments