1

我正在使用带有 ruby​​ 1.9.3 的 Rails 3.2.9(默认使用 RVM)。当我执行命令'rails console'/'rails c'时,从我的test_app的根目录中,显示以下错误。

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>'

谁能帮我解决这个问题?

4

3 回答 3

2

是的,我得到了我的问题的答案。

只需在应用程序文件夹的根目录中打开文件“Gemfile”,然后将下面的行粘贴到那里。

gem 'execjs'

gem 'libv8'

gem 'therubyracer'

粘贴后,只需保存文件并在命令提示符下执行“捆绑更新”。

成功完成包更新后,您尝试运行“rails c”或“rails console”以获取 rails 控制台。有用!!

谢谢你。

于 2012-12-13T05:42:25.810 回答
1

尝试安装

gem 'therubyracer'

资源

高温高压

于 2012-12-13T04:26:01.007 回答
1

安装以下两个:

gem 'execjs'
gem 'therubyracer'
于 2012-12-13T04:27:08.420 回答