A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

Ruby on Rails: execjs Javascript runtime error when executing “rails server”

My schedule right now is not very tight and I have a couple of hours free almost everyday. So instead of playing Skyrim, I am learning Ruby on Rails.

I am using RVM (http://beginrescueend.com/) on Ubuntu Ubuntu 10.04 LTS (Lucid Lynx).

Here is the error I get when I try to run “rails server”:

wenbert@ubuntu:~/projects/rails/depot$ rails server
/home/wenbert/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.12/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)
	from /home/wenbert/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.12/lib/execjs.rb:5:in `<module:ExecJS>'
	from /home/wenbert/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.12/lib/execjs.rb:4:in `<top (required)>'
	from /home/wenbert/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
	from /home/wenbert/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
	from /home/wenbert/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
	from /home/wenbert/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
	from /home/wenbert/.rvm/gems/ruby-1.9.2-p290/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `require'
	from /home/wenber

A lot of people have already experienced this error. There is a popular thread for this in Stackoverflow – here. The Original Poster of the thread selected the this answer:

I’m on Ubuntu 11.04. Had similar issues. Installing node.js fixed this for me


But I think the more appropriate answer is the one by vincent jacquel in this thread.

The Fix

  1. Open the Gemfile
  2. Add these lines:
    gem 'execjs'
    gem 'therubyracer'
  3. Save.
  4. Then run this command: $> bundle after
This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to Ruby on Rails: execjs Javascript runtime error when executing “rails server”

  1. Jojo Siao says:


    I also encountered that. so yeah, that is a very common issue. RoR integrated coffeescript in 3.1

  2. jagat says:

    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
    make install

    Jagat Singh

  3. system says:

    Thanks for the fix. Ruby on Rails is awesome but has a couple tricks you need to know.

  4. Wenbert Del Rosario says:

    @jagat, that would also solve the problem but IMHO it is not the best way…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>