ExecJS missing runtime message needs to be improved #412

joneslee85 opened this Issue May 6, 2011 · 20 comments


None yet

Got error when trying to start WebBrick

/home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/execjs-0.3.2/lib/execjs.rb:32:in `runtime': Could not find a JavaScript runtime (ExecJS::RuntimeError)
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/execjs-0.3.2/lib/execjs.rb:44
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/coffee-script-2.2.0/lib/coffee_script.rb:1
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/coffee-script-2.2.0/lib/coffee-script.rb:1
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/actionpack-3.1.0.beta1/lib/sprockets/railtie.rb:4:in `require'
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/actionpack-3.1.0.beta1/lib/sprockets/railtie.rb:4:in `using_coffee?'
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/actionpack-3.1.0.beta1/lib/sprockets/railtie.rb:17
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/actionpack-3.1.0.beta1/lib/action_controller/railtie.rb:7:in `require'
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/actionpack-3.1.0.beta1/lib/action_controller/railtie.rb:7
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/activerecord-3.1.0.beta1/lib/active_record/railtie.rb:9:in `require'
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/activerecord-3.1.0.beta1/lib/active_record/railtie.rb:9
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/railties-3.1.0.beta1/lib/rails/all.rb:11:in `require'
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/railties-3.1.0.beta1/lib/rails/all.rb:11
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/railties-3.1.0.beta1/lib/rails/all.rb:5:in `each'
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/railties-3.1.0.beta1/lib/rails/all.rb:5
    from /home/mojo/Sites/hello/config/application.rb:3:in `require'
    from /home/mojo/Sites/hello/config/application.rb:3
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/railties-3.1.0.beta1/lib/rails/commands.rb:51:in `require'
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/railties-3.1.0.beta1/lib/rails/commands.rb:51
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/railties-3.1.0.beta1/lib/rails/commands.rb:48:in `tap'
    from /home/mojo/.rvm/gems/ree-1.8.7-2011.03@rails31/gems/railties-3.1.0.beta1/lib/rails/commands.rb:48
    from script/rails:6:in `require'
    from script/rails:6

@josh josh was assigned May 6, 2011
Ruby on Rails member

@joneslee85, you need an ExecJS runtime, one of the several listed here: https://github.com/sstephenson/execjs

@josh I have seen this question also coming up on twitter. Can we change execjs message again? Maybe we could say something like: "Could not find a JavaScript runtime. Please install one of the following: [list of available runtimes]. You can read more about it here: [link to execjs project]."

@joneslee85 joneslee85 closed this May 6, 2011
@joneslee85 joneslee85 reopened this May 7, 2011

I re-open this issue because I still get the same error ONLY on my Linux box even though execjs 0.3.2 and 0.3.3 is there. Steps to re-produce:

$ rvm gemset create rails31
$ rvm use ree@rails31
$ gem install rails --pre
$ rails new testo
$ cd testo
$ bundle install
$ rails s

EDIT: Works with OSX. Got problem with Ubuntu 11.04 (2.6.38-8-generic) + ree-1.8.7-2011.03 [ i386 ]

Ruby on Rails member

Yes, you need to install one of the runtimes I linked above. Meanwhile we will improve the ExecJS message, please don't close the ticket.

Ruby on Rails member
Ruby on Rails member

Sweet, thanks @josh.

@josevalim josevalim closed this May 7, 2011

Hi guys i also got the same problem, but i added "therubyracer" on Gemfile it works fine. My question is keep adding like this for all new projects?


I am following the steps in Rails Guide 3.1.
I had to add gem 'therubyracer' to avoid errors.
Again is this how we have to do for any new rails project?


follow the below command so that you don't need to run( gem 'therubyracer' & bundle install ) for every new project

  1. Install the CentOS development tools package – sudo yum groupinstall 'Development Tools'
  2. Install the Open SSL development package (This is required for Node.js to support HTTPS) – sudo yum install openssl-devel
  3. Find a convenient place to download the Node.js package. I used the root directory – cd /root
  4. Download the Node.js package (Check the Node.js site for the latest version) – wget http://nodejs.org/dist/node-v0.4.8.tar.gz
  5. Unzip the downloaded Node.js package – gunzip node-v0.4.8.tar.gz
  6. Unpack the contents of node-v0.4.8.tar – tar -xf node-v0.4.8.tar
  7. Set 6. should have created a directory under the directory that you are currently in. In my case, I was in /root. CD into that directory – cd node-v0.4.8
  8. Run configure – ./configure
  9. Build Node.js – make
  10. Install your Node.js build – make install

I think adding the gem is much simpler


no that is very simple & dont need to set gem 'therubyracer' & bundle install for any new project
i write it again in simple way:
wget http://nodejs.org/dist/node-v0.4.8.tar.gz
gunzip node-v0.4.8.tar.gz
tar -xf node-v0.4.8.tar
cd node-v0.4.8
make install


I don't understand why the Rails 3.1 new project generator doesn't just include a gem in your Gemfile with a javscript runtime -- since by default it's including gems that require a javascript runtime. I don't understand the rationale of having the default app generator produce an app that you can't actually run, not even to get the 'hello world' message.

What am i missing? At the very least, some documentation should be provided in a prominent place (the 'getting started' Guide?) explaining whatever it is I'm missing; the present situation is very confusing for people getting started.

Ruby on Rails member

@jrochkind the new project generator doesn't include a javascript runtime by default because no all the users need a gem for it: Mac OS X include a JavascriptCore runtime by default, Windows include Windows Script Host by default and some others users have Node.js installed.


I had this problem, too. I run Linux and didn't have node.js installed before I read this thread. Once installed, my Rails 3.1 app ran without the ExecJS error.

If you're running Ubuntu 10.10 as I am, running 'sudo aptitude install nodejs' will install node.js. It provided the javascript runtime that execjs could use in my Rails 3.1 app and I didn't need to do anything to tell ExecJS how to find it.

I think your answer, @guilleiguaran is right on. I think it's good that the generator doesn't provide a javascript runtime. At least for now. At the same time, the tutorials would be more helpful by providing a note about this dependency and link or two pointing to more information. So I agree with you, @jrochkind, it's confusing at first.


Oh Great, pjmelling, you are ready, Thanks for Collaboration.


I echo jrochkind's comment. It's a little ridiculous that you can't run a freshly generated Rails app in Linux unless node.js is installed. Is there a reason why the rails new generator doesn't add therubyracer (or therubyrhino for JRuby) to the Gemfile, if there is no Javascript runtime on the system? I think I will issue a fix for this and issue a pull request.

Ruby on Rails member

@brentsowers1 we discussed it in #3619.

in the next versions of Rails (starting with 3.1.x) therubyrhino will be included by default on Gemfile if JRuby is detected.


I'm working on a fix now, I just looked at the way execjs does it and copied that approach. I'm testing my fix on Windows now (Windows doesn't need a gem added), once I verify that I'll issue a pull request.


I've fixed this now, running rails new on a Linux system that does not have node.js will add therubyracer to the Gemfile. I've created 3 pull requests:
For Rails 3.1 - #4407
For Rails 3.2 - #4406
For Rails master - #4405

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment