Skip to content

ExecJS missing runtime message needs to be improved #412

Closed

Description

@runlevel5

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


Activity

  1. ghost assigned on May 6, 2011
  2. josevalim commented on May 6, 2011

    @josevalim
    Contributor

    @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]."

  3. runlevel5 commented on May 7, 2011

    @runlevel5
    ContributorAuthor

    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 ]

  4. josevalim commented on May 7, 2011

    @josevalim
    Contributor

    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.

  5. josh commented on May 7, 2011

    @josh
    Contributor
  6. josevalim commented on May 7, 2011

    @josevalim
    Contributor

    Sweet, thanks @josh.

  7. demonchand commented on May 17, 2011

    @demonchand

    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?

  8. ramgole commented on Sep 1, 2011

    @ramgole

    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?

  9. samirafk commented on Sep 23, 2011

    @samirafk

    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
  10. ramgole commented on Sep 24, 2011

    @ramgole

    I think adding the gem is much simpler

  11. samirafk commented on Sep 24, 2011

    @samirafk

    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
    ./configure
    make
    make install

  12. jrochkind commented on Sep 29, 2011

    @jrochkind
    Contributor

    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.

  13. guilleiguaran commented on Sep 29, 2011

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

  14. pjmelling commented on Oct 12, 2011

    @pjmelling

    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.

  15. renatosousafilho commented on Oct 31, 2011

    @renatosousafilho

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

  16. brentsowers1 commented on Jan 11, 2012

    @brentsowers1

    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.

  17. guilleiguaran commented on Jan 11, 2012

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

  18. jrochkind commented on Jan 11, 2012

    @jrochkind
    Contributor

    @brentsowers1 I was trying to think through methods in which the rails
    installer could determine if a JS runtime was available at generation
    time, to add the Gemfile dependency if it's not. I can't think of any
    way but FIRST installing the execjs gem (if it's not installed?) and
    use it's API to determine if there's an available runtime (which
    probably means there needs to be a version dependency on execjs since
    it's using it's API). Maybe first install the Gemfile as it now (which
    includes an execjs indirect dependency), then 'bundle install', THEN
    (after Bundler.setup to get that dependency) use the execjs API, and
    if neccesary (and it's MRI) THEN add therubyracer dependency. But
    'bundle install' in 'Bunder.setup' are so sadly slow (especially when
    run via subshell, isn't there bundler api to do that instead? and
    especially under 1.9.x, even 1.9.3), that doing extra ones like this
    is a drag. So I'm not sure.

    I had only thought a bit, not started coding. I encourage you to try
    to figure it out and pull request, and hope the committers would
    accept such a thing. It definitely seems to me that 'rails new' ought
    to give you a runnable app on linux, which it does not currently.

    On Jan 10, 2012, at 10:34 PM, Guillermo Iguaran wrote:

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


    Reply to this email directly or view it on GitHub:
    #412 (comment)

  19. brentsowers1 commented on Jan 11, 2012

    @brentsowers1

    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.

  20. brentsowers1 commented on Jan 11, 2012

    @brentsowers1

    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

  21. added a commit that references this issue on Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions