简体   繁体   English

'rails console'命令在Rails 3.2.9中抛出错误

[英]'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). 我使用Rails 3.2.9与ruby 1.9.3(默认使用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'/'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>'

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. 只需在应用程序文件夹的根目录中打开文件“Gemfile”,然后在其中粘贴以下行。

gem 'execjs'

gem 'libv8'

gem 'therubyracer'

After pasting it, just save the file and execute 'bundle update' on the command prompt. 粘贴后,只需保存文件并在命令提示符下执行“bundle update”。

On finishing bundle update successfully, you try running 'rails c' or 'rails console' for taking the rails console. 成功完成捆绑包更新后,您可以尝试运行“rails c”或“rails console”来获取rails控制台。 It works!! 有用!!

Thank you. 谢谢。

try installing 尝试安装

gem 'therubyracer'

source 资源

HTH HTH

Install the folowing both: 安装以下两个:

gem 'execjs'
gem 'therubyracer'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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