Skip to content

Could not find a JavaScript runtime #31

sheldonh opened this Issue Jun 8, 2011 · 23 comments
sheldonh commented Jun 8, 2011

Targetting rails-3.1.0.rc2, I tried using a railswizard with the following recipes:

  • Cucumber
  • Git
  • Mongoid
  • RSpec
  • SASS

The generate commands all failed because execjs was unable to find a JavaScript runtime. For example:

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
wizard    Running after Bundler callbacks
generate  cucumber:install --capybara --rspec -D
.../gems/execjs-1.1.1/lib/execjs/runtimes.rb:43:in `autodetect': Could not find a JavaScript runtime. See for a list of available runtimes. (ExecJS::RuntimeUnavailable)

I worked around this by

  • deleting the new app,
  • installing therubyracer --pre,
  • running the railswizard-assisted rails new app command again,
  • adding therubyracer to the Gemfile in the generated app, and
  • running the failed targets (cucumber:install, mongoid:config, rspec:install) by hand.

check through this URL..I would be helpful.


My point is that the rails wizard probably needs to know what version of rails it's targetting, and add therubyracer for 3.1.


Thanks sheldonh! After fixing many many issues I couldn't figure out why rails worked perfect in my shell (fixed all issues with this original shell). But when opening new shells rails no longer worked. I would get the following error:

bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file or directory

Then after reading your last comment it hit me, so obvious. After installing and reinstalling rails so many times, I had forgotten to set 1.9.2 as my default with:

$ rvm use 1.9.2 --default

Banta commented Dec 2, 2011

On my linux (ubuntu) the command

sudo apt-get install nodejs

did the job finally for me.

dagosi89 commented Dec 7, 2011

Thanks Banta, it works for me. (Ubuntu 11.04)




it works,great!

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

Banta commented Jan 6, 2012

If nodejs and other fails to work you can you can start your rails command with bundle exec e.g

      bundle exec rails s
      bundle exec rake db:create
      ... etc


cue232s commented Feb 4, 2012

@Banta thanks!


being on this page
never once did he say anything about shutting coffee-script off. I know that it is possible but not well documented.
I do not have a javascript engine like nodejs and it ruins my restful experience with Rails. See error below from doing
Rendered users/index.html.erb within layouts/application (66.6ms)
Completed 500 Internal Server Error in 2853ms

ActionView::Template::Error (/usr/bin/js: 22: /usr/bin/java: not found

(in /home/kb9agt/My_Repositories_Github/rails_projects/demo_app/app/assets/javascripts/
4: DemoApp
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
app/views/layouts/application.html.erb:6:in _app_views_layouts_application_html_erb__189663113_74149310'
I will not use node.js because of this: 1.) Why is rails being so nosy with my system? I am a user not a system. It has no business needing anything from my system. Not even Ruby is at the system level as an rvm user.


To me too.... Thanks!


rubyracer gem is the answer for me. :-D

Banta commented Apr 21, 2012

@DouglasAllen I'll have to try that out.

yoniix commented Apr 21, 2012



Looks like SheldonH used one of those Rmagic samples on himself there. :-D

Ganyobi commented May 15, 2012

Thanks Banta, installing nodejs worked


@DouglasAllen 11 months ago, dude.


sorry in which path we should type:
"$ gem install execjs"
I installed it every where but didn't work! :(


@sheldonh The RMagic or my comment? Close err up then. 👍


Sure thing. We'll call it working as intended. :-)

@sheldonh sheldonh closed this Aug 26, 2014
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.