Default Gemfile, " Could not find a JavaScript runtime" #2963

jrgifford opened this Issue Sep 9, 2011 · 10 comments


None yet

6 participants


I run rails new project on Ubuntu 11.04, and I get the following when I try to run rails server:

/home/jrg/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.4/lib/execjs/runtimes.rb:45:in autodetect': Could not find a JavaScript >runtime. See for a list of available runtimes. (ExecJS::RuntimeUnavailable)

However, it's fixed by added gem 'therubyracer' to my Gemfile, and running bundle install again.

Why isn't it in the default Gemfile?


Because it's only one of the runtimes and it only works when you can compile c extensions (i.e. not Windows or jruby).
Also prevents usage of external runtimes.

The preferred runtime for Ubuntu is node. sudo apt-get install nodejs.


Thanks - however, there should be some way to have it added to the
gemfile automatically, or have a message - it's somewhat disruptive
when you run into that the first time.


Is difficult set a standard JavaScript runtime in the Gemfile:

  • Mac OS X include Apple JavaScriptCore, then you don't need to install any extras.
  • Windows include Microsoft Windows Script Host, then you don't need to install any extras.
  • therubyracer, mustang, johnson don't work on Windows or under JRuby.
  • therubyrhino works only under JRuby.
  • Node.js is probably the unique alternative that works in the three systems but we don't want force to the users to install it.

I see. Well, in that case, can I suggest that a message in the Gemfile say something like "You need to add a JS runtime - Mac users are fine, Windows is fine, Linux and jRuby folks need to install something from here"?

Reason I say in the actual Gemfile is because I (and most other devs I know) read their Gemfile to make sure things are A-OK.


Let me add a +1 for making it "Just Work". 3.0.9 "Just Works" when you run rails server ... I know you guys don't want to force us to use a particular JS run-time, but to get to step 3 (from 'Make your application' on and throw an error is just plain inelegant. Besides, I thought it was an opinionated framework?

Why not just require Node.js and include in the documentation how to switch to one of the other alternatives? Or, just document it so that we know we have to download one. I spent 30 minutes tracking this down and still managed to not pick the preferred JS run-time. It would also be helpful if execjs would provide a preferred list as Samuel did above, so that the neo-newbs (getting back into Rails after a hiatus) might be able to buy a vowel. But I digress.


It would be really nice if this requirements were removed from the base Gemfile. It's a PITA for new users who try Rails now to figure this stuff out. People should be required to select SCSS and a JS runtime instead of being forced and not being able to run Rails at all for the first time.


I'm working in a solution for this, I will add therubyracer/therubyrhino under Linux/*BSD/etc when Node.js isn't present

@guilleiguaran guilleiguaran added a commit to guilleiguaran/rails that referenced this issue Nov 12, 2011
@guilleiguaran guilleiguaran Add therubyracer/therubyrhino to Gemfile when there isn't a JS Runtim…
…e available in the system. Closes #2963

There isn't a clean way to do this automatically, the best option for now will be update the docs to reflect this.

j4jagat commented Jan 6, 2012

Install JavaScript runtime environment in your systems by using following steps. this is best way to sole

tar xfv node-v0.1.31.tar.gz
cd node-v0.1.31
make install

Jagat Singh


This the current status of this:

  • Under JRuby therubyrhino is added to Gemfile
  • Under other Rubies therubyracer is added to Gemfile commented, Linux users without SpiderMonkey/Node.js can uncomment it to use
  • The Getting Started Guide is updated to reflect the changes

I'm closing this issue for now.

@croaky croaky referenced this issue in thoughtbot/laptop Feb 20, 2014

Rake #194

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