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

Closed
jrgifford opened this Issue Sep 9, 2011 · 10 comments

Comments

Projects
None yet
6 participants
@jrgifford
Contributor

jrgifford commented Sep 9, 2011

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?

@samuelkadolph

This comment has been minimized.

Show comment
Hide comment
@samuelkadolph

samuelkadolph Sep 9, 2011

Contributor

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.

Contributor

samuelkadolph commented Sep 9, 2011

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.

@jrgifford

This comment has been minimized.

Show comment
Hide comment
@jrgifford

jrgifford Sep 9, 2011

Contributor

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.

Contributor

jrgifford commented Sep 9, 2011

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.

@guilleiguaran

This comment has been minimized.

Show comment
Hide comment
@guilleiguaran

guilleiguaran Sep 9, 2011

Member

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.
Member

guilleiguaran commented Sep 9, 2011

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.
@jrgifford

This comment has been minimized.

Show comment
Hide comment
@jrgifford

jrgifford Sep 10, 2011

Contributor

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.

Contributor

jrgifford commented Sep 10, 2011

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.

@rsimplicio

This comment has been minimized.

Show comment
Hide comment
@rsimplicio

rsimplicio Sep 11, 2011

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.

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.

@mauricio

This comment has been minimized.

Show comment
Hide comment
@mauricio

mauricio Oct 16, 2011

Contributor

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.

Contributor

mauricio commented Oct 16, 2011

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.

@guilleiguaran

This comment has been minimized.

Show comment
Hide comment
@guilleiguaran

guilleiguaran Oct 16, 2011

Member

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

Member

guilleiguaran commented Oct 16, 2011

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

@guilleiguaran

This comment has been minimized.

Show comment
Hide comment
@guilleiguaran

guilleiguaran Dec 19, 2011

Member

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

Member

guilleiguaran commented Dec 19, 2011

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

@j4jagat

This comment has been minimized.

Show comment
Hide comment
@j4jagat

j4jagat Jan 6, 2012

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

j4jagat commented Jan 6, 2012

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

@guilleiguaran

This comment has been minimized.

Show comment
Hide comment
@guilleiguaran

guilleiguaran Jan 14, 2012

Member

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.

Member

guilleiguaran commented Jan 14, 2012

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

Closed

Rake #194

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