Problem deploying Rails 3.1 project to Heroku: Could not find a JavaScript runtime Problem deploying Rails 3.1 project to Heroku: Could not find a JavaScript runtime ruby ruby

Problem deploying Rails 3.1 project to Heroku: Could not find a JavaScript runtime


You need a JavaScript engine for Rails 3.1 (heroku doesn’t have one), and it appears that the JavaScript engine that works with Heroku is the rubyracer for heroku.

Rails uses execjs to execute JavaScript and execjs supports 7 JavaScript engines. Node.js is one, and rubyracer is one.

Gerred Dillon had a similar problem and wrote about it. In the comment section a point was raised about making this a production only change, since you already have nodejs as your local JavaScript engine. So the relevant code is:

group :production do  gem 'therubyracer-heroku', '0.8.1.pre3'end

UPDATE: Heroku has a new stack, called Cedar, that they recommend for Rails 3.1.0. (Run heroku stack to see what stack your app is on.) Heroku also has a doc about upgrading to Rails 3.1.0 rc5. They recommend not using the ‘therubyracer-heroku’ gem anymore as it’s not necessary with rc5.

If you are upgrading from an older rc, make sure to update your config/application.rb file, and also run this command:

heroku config:add PATH=vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin:bin

Apparently, this is set in new apps, but existing apps have not set this PATH.


You don't necessarily need a JavaScript runtime to deploy Rails 3.1 beta to heroku.

The JavaScript runtime is only required if you are minifying javascript on deployment (i.e., via the uglifier gem) or if you are using coffee-script.

It looks like this javascript runtime dependency will not be there for the 3.1 final release.

In case you don't mind not minifying your javascript (and also if you're not using coffee-script), then you can comment out the coffee-script, uglifier and execjs gems in the Gemfile and also comment out config.assets.js_compressor in your production.rb and you should be good to go.


As of the date of this post you still need to specify

gem 'therubyracer-heroku', '0.8.1.pre3'

in your gemfile in order to successfully deploy a Rails 3.1 app to Heroku's Cedar platform.

While it is possible to deploy Node apps to the Cedar platform, Node itself is not present on the Cedar stack when deploying Rails apps, so you have to bundle your own javascript runtime.

For now.

I know the people on the Rails side of things are working to remove the dependency on having a js runtime, http://yehudakatz.com/2011/06/14/what-the-hell-is-happening-to-rails/ and I'm sure that Heroku is also looking into ways to make Rails 3.1 deployments just work.