4

It's Rails 3.1.0

What I did:

rails new site
cd site
rails s

The message I got:

/home/user1/.rvm/gems/ruby-1.9.2-p180/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)
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/execjs-1.2.9/lib/execjs.rb:5:in `<module:ExecJS>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/execjs-1.2.9/lib/execjs.rb:4:in `<top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `<top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
    from /home/user1/social/config/application.rb:7:in `<top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:52:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:52:in `block in <top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:49:in `tap'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:49:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Why did I get this error?

Can anyone give hint to fix it?

juliomalegria
  • 24,229
  • 14
  • 73
  • 89
cola
  • 12,198
  • 36
  • 105
  • 165

5 Answers5

3

As the error mentions, you do not have a Javascript runtime installed. You should pick one yourself.

Add this to your Gemfile:

gem "therubyracer"

Then run bundle install and try again.

molf
  • 73,644
  • 13
  • 135
  • 118
3

You may also need to install node.js (helped for me)

Sławosz
  • 11,187
  • 15
  • 73
  • 106
2
$sudo apt-get install nodejs

worked for me...

animuson
  • 53,861
  • 28
  • 137
  • 147
Dan
  • 21
  • 1
1

Just Open the file 'Gemfile' inside the root directory of your application folder, and then paste the below lines there.

gem 'execjs'

gem 'libv8'

gem 'therubyracer'

After pasting it, just save the file and execute 'bundle update' on the command prompt.

On finishing bundle update successfully, you try running 'rails s'. It works!!

Thank you.

Rajesh Omanakuttan
  • 6,788
  • 7
  • 47
  • 85
0

By seeing your question, your system complains about the lack of JavaScript runtime.

you should visit https://github.com/sstephenson/execjs for a list of possibilities.

I would suggest you to download node.js from this http://nodejs.org/.

follow this way:

cd *your download dir*
tar xvf node-v0.4.11.tar.gz
cd node-v0.4.11
./configure
make
sudo make install

I am giving this answer because this works for me.

This answer will helpful to you.

Jaimin pandya
  • 473
  • 1
  • 6
  • 12