2012-12-13 60 views
1

我正在使用Rails 3.2.9和ruby 1.9.3(使用RVM進行默認設置)。從我的test_app的根目錄執行命令'rails console'/'rails c'時,顯示以下錯誤。'rails console'命令在Rails 3.2.9中拋出錯誤

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/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require' 
    from /home/local/rajesh.co/.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require' 
    from /home/local/rajesh.co/.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each' 
    from /home/local/rajesh.co/.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require' 
    from /home/local/rajesh.co/.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each' 
    from /home/local/rajesh.co/.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require' 
    from /home/local/rajesh.co/.rvm/gems/[email protected]/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>' 

任何人都可以幫助我解決這個問題嗎?

回答

2

是的,我有我的問題的答案。

只需打開應用程序文件夾根目錄下的文件'Gemfile',然後將下面的行粘貼到那裏。

gem 'execjs' 

gem 'libv8' 

gem 'therubyracer' 

粘貼後,只要保存文件並執行命令提示符「捆綁更新」。

成功完成軟件包更新後,您嘗試運行'rails c'或'rails console'來獲取rails控制檯。有用!!

謝謝。

1

嘗試安裝

gem 'therubyracer' 

source

HTH

+0

不行!我安裝了gem'therubyracer'和gem'execjs'並進行了捆綁更新。它不工作,同樣的錯誤再次顯示。 –

+1

嗨@Rajesh,好像你在這裏使用rvm,那麼你確定你將寶石捆綁在正確的rvm包中嗎? – sameera207

+0

我不明白。你能澄清這個問題嗎? –

1

安裝如下因素都:

gem 'execjs' 
gem 'therubyracer' 
+0

不行!我安裝了gem'therubyracer'和gem'execjs'並進行了捆綁更新。它不工作,同樣的錯誤再次顯示。 –

+1

嘗試運行'捆綁安裝'而不是'捆綁更新' – VenkatK

+0

我已經這樣做了,並且我在上面的評論中提到過。 –