简体   繁体   中英

'rails console' command throwing error in Rails 3.2.9

I am using Rails 3.2.9 with ruby 1.9.3 (made default using RVM). From the root directory of my test_app when I executed the command 'rails console' / 'rails c', the following error is showing.

rails console
/home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327/gems/execjs-1.4.0/lib/execjs.rb:4:in `<top (required)>'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `<top (required)>'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
    from /home/local/rajesh.co/Rajesh/blog/config/application.rb:7:in `<top (required)>'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/commands.rb:39:in `require'
    from /home/local/rajesh.co/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/commands.rb:39:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Can anyone help me to resolve this?

Yes, I got the answer for my question.

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 c' or 'rails console' for taking the rails console. It works!!

Thank you.

try installing

gem 'therubyracer'

source

HTH

Install the folowing both:

gem 'execjs'
gem 'therubyracer'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM