2014-06-21 56 views
0

您好,我正在使用Windows 8上的導軌上的紅寶石,我很難在我的機器上設置ruby 2.1。當我運行軌道的I得到以下錯誤:rails s命令不起作用

C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.2.0/lib/execjs/run 
times.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://gi 
thub.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUn 
available) 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.2.0/l 
ib/execjs.rb:5:in `<module:ExecJS>' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.2.0/l 
ib/execjs.rb:4:in `<top (required)>' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.5.1 
/lib/uglifier.rb:3:in `require' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.5.1 
/lib/uglifier.rb:3:in `<top (required)>' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/ 
lib/bundler/runtime.rb:76:in `require' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/ 
lib/bundler/runtime.rb:76:in `block (2 levels) in require' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/ 
lib/bundler/runtime.rb:72:in `each' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/ 
lib/bundler/runtime.rb:72:in `block in require' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/ 
lib/bundler/runtime.rb:61:in `each' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/ 
lib/bundler/runtime.rb:61:in `require' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/ 
lib/bundler.rb:132:in `require' 
     from C:/HandCo-op/HandCo-op/config/application.rb:7:in `<top (required)> 
' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2 
.rc1/lib/rails/commands/commands_tasks.rb:79:in `require' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2 
.rc1/lib/rails/commands/commands_tasks.rb:79:in `block in server' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2 
.rc1/lib/rails/commands/commands_tasks.rb:76:in `tap' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2 
.rc1/lib/rails/commands/commands_tasks.rb:76:in `server' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2 
.rc1/lib/rails/commands/commands_tasks.rb:40:in `run_command!' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2 
.rc1/lib/rails/commands.rb:17:in `<top (required)>' 
     from bin/rails:4:in `require' 
     from bin/rails:4:in `<main>' 

我想這是因爲我需要紅寶石2.1和安裝的版本是2.0。有誰知道我應該如何解決這些錯誤?非常感謝任何人有一個想法,爲什麼我不能運行rails s。

+0

Protip,堆棧跟蹤通常會給出原因的線索,或者至少是問題出在哪裏。儘管第一行非常神祕,但下一步您可以通過https://github.com/sstephenson/execjs獲取更多信息。 – Unixmonkey

回答

2

這很有趣,我剛剛用ruby 2.1初始化了一個新的rails 4項目,忘記更新Gemfile幾分鐘前我收到了確切的錯誤消息。

更新您的Gemfile取消註釋gem 'therubyracer'線,所以它看起來像:

# Gemfile 
gem 'therubyracer', platforms: :ruby 

運行更新Gemfilebundle命令。

錯誤消息是因爲您沒有安裝運行系統。

更新:在Windows

選項我已經成功安裝和使用Windows 7+ 64拱closure-compiler寶石。我的發展框從Linux切換到窗口不時所以以下是我有我的Gemfile設置:

# Gemfile 

gem 'therubyracer', :platforms => :ruby 
gem 'execjs', :platforms => :ruby 

gem 'closure-compiler' 

,並通過更新以下行更新的或者您的環境中配置config/environments/或應用寬config/application.rb

config.assets.js_compressor = :closure 

有關RailsGuide的更多信息,請參閱Customizing the Pipeline

+0

我試過了,得到了同樣的錯誤。然而,在取消註釋該行並運行軟件包安裝後,我沒有看到正在安裝therubyracer。 – ZachyBear

+0

@ZachyBear,請參閱更新。希望有所幫助! – vee