3

I've used rvm to install rails..no problems.

Created a new app successfully

Running bundle install without issues.

Although, trying to run any command further (rails s, rails g controller.., etc)

I'm getting this error

    /home/USER/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.9/lib/execjs              /runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

I'm assuming there's an issue with a gem but I'm really clueless on what happened and can't seem to find anything that addresses this issue

mgaughan
  • 875
  • 7
  • 23
  • 1
    possible duplicate of [Rails 3.1 error - Could not find a JavaScript runtime?](http://stackoverflow.com/questions/7092107/rails-3-1-error-could-not-find-a-javascript-runtime) – Gazler Nov 16 '11 at 20:25
  • You may want to add your name to the list of affected users on the launchpad bug report: https://bugs.launchpad.net/turnkeylinux/+bug/1084235 – Barton Chittenden Apr 21 '13 at 14:57

4 Answers4

8

This happens when your ubuntu installation does not have a javascript runtime installed.

Try:

sudo apt-get install nodejs
Ken Li
  • 2,578
  • 4
  • 25
  • 26
  • This is a better solution than just monkey-patching by adding the ruby racer gem, which is known to use a lot of memory, and don't need be included in the latest Rails versions. – Yosep Kim Aug 24 '13 at 12:21
3

I had the best experience with using therubyracer on Ubuntu / Xubuntu (this is the Google V8 runtime) and Node.js in Windows. So basically yes, just adding

gem 'therubyracer'

to your Gemfile and running bundle install is enough. Node.js is not required.

Also take a look at: https://github.com/sstephenson/execjs

Florin Gogianu
  • 338
  • 4
  • 10
2

Add this to your Gemfile

gem 'therubyracer'

then run bundle install and you should be good to go!

nathanvda
  • 49,707
  • 13
  • 117
  • 139
0

I had the same issue.

Gemfile ->

gem 'execjs'
gem 'rubytheracer'

bundle install

lucapette
  • 20,564
  • 6
  • 65
  • 59
SG 86
  • 6,974
  • 3
  • 25
  • 34
  • `execjs` is not needed, that is a standard dependency of Rails. The error is generated by `execjs`, so OP already has that. – nathanvda Nov 16 '11 at 21:13