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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)