Skip to content
This repository

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

Closed
jrgifford opened this Issue September 09, 2011 · 10 comments

6 participants

James Gifford Guillermo Iguaran Samuel Kadolph Robert Simplicio Maurício Linhares j4jagat
James Gifford

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 https://github.com/sstephenson/execjs 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?

Samuel Kadolph

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.

James Gifford
Guillermo Iguaran

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.
James Gifford

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 https://github.com/sstephenson/execjs"?

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.

Robert Simplicio

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 rubyonrails.org) 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.

Maurício Linhares

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.

Guillermo Iguaran

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

Guillermo Iguaran guilleiguaran referenced this issue from a commit in guilleiguaran/rails October 18, 2011
Guillermo Iguaran Add therubyracer/therubyrhino to Gemfile when there isn't a JS Runtim…
…e available in the system. Closes #2963
c267f11
Guillermo Iguaran

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

j4jagat

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

wget http://nodejs.org/dist/node-v0.1.31.tar.gz
tar xfv node-v0.1.31.tar.gz
cd node-v0.1.31
./configure
make
make install

Thanks,
Jagat Singh

Guillermo Iguaran

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.

Guillermo Iguaran guilleiguaran closed this January 14, 2012
Dan Croak croaky referenced this issue in thoughtbot/laptop February 20, 2014
Closed

Rake #194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.