2012-01-20 330 views
1

當我運行rake assets:precompile時,出現異常錯誤。我正在使用jruby 1.6.5.1,並且該問題只發生在一臺機器上,但對其他機器工作正常。Rails 3.1預編譯資產錯誤

[[email protected] someapp]$ rake assets:precompile --trace 
** Invoke assets:precompile (first_time) 
** Execute assets:precompile 
/home/x/.rvm/rubies/jruby-1.6.5.1/bin/jruby /home/x/.rvm/gems/jruby-1.6.5.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace 
** Invoke assets:precompile:all (first_time) 
** Execute assets:precompile:all 
** Invoke assets:precompile:primary (first_time) 
** Invoke assets:environment (first_time) 
** Execute assets:environment 
** Invoke environment (first_time) 
** Execute environment 
** Invoke tmp:cache:clear (first_time) 
** Execute tmp:cache:clear 
** Execute assets:precompile:primary 
rake aborted! 
partial character in source, but hit end near �\")&& (k=/^[\\s\\xA0]+/,l=/[\\s\\xA0]+$/),h=e(c),c.addEventListener...... 
.............................. 
(in /home/x/someapp/cmeng/app/assets/javascripts/application.js) 
json/ext/Parser.java:249:in `parse' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/json-1.6.1-java/lib/json/common.rb:148:in `parse' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/multi_json-1.0.3/lib/multi_json/engines/json_gem.rb:13:in `decode' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/multi_json-1.0.3/lib/multi_json.rb:65:in `decode' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/execjs-1.2.9/lib/execjs/external_runtime.rb:61:in `extract_result' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/execjs-1.2.9/lib/execjs/external_runtime.rb:27:in `exec' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/execjs-1.2.9/lib/execjs/external_runtime.rb:40:in `compile_to_tempfile' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/execjs-1.2.9/lib/execjs/external_runtime.rb:26:in `exec' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/uglifier-1.0.4/lib/uglifier.rb:95:in `compile' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/actionpack-3.1.1/lib/sprockets/compressors.rb:18:in `compress' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/processing.rb:265:in `js_compressor=' 
org/jruby/RubyProc.java:270:in `call' 
org/jruby/RubyProc.java:220:in `call' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/processor.rb:29:in `evaluate' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/context.rb:175:in `evaluate' 
org/jruby/RubyArray.java:1612:in `each' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/context.rb:172:in `evaluate' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:242:in `build_source' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/caching.rb:30:in `cache_hash' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:235:in `build_source' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:71:in `digest' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/asset.rb:95:in `digest_path' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/actionpack-3.1.1/lib/sprockets/static_compiler.rb:58:in `path_for' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/actionpack- 3.1.1/lib/sprockets/static_compiler.rb:35:in `write_asset' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/actionpack-3.1.1/lib/sprockets/static_compiler.rb:21:in `compile' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/base.rb:151:in `each_logical_path' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/base.rb:139:in `each_file' 
org/jruby/RubyArray.java:1612:in `each' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/base.rb:129:in `each_entry' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/base.rb:137:in `each_file' 
org/jruby/RubyArray.java:1612:in `each' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/base.rb:136:in `each_file' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/sprockets-2.0.3/lib/sprockets/base.rb:149:in `each_logical_path' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/actionpack-3.1.1/lib/sprockets/static_compiler.rb:18:in `compile' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/actionpack-3.1.1/lib/sprockets/assets.rake:52:in `internal_precompile' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/actionpack-3.1.1/lib/sprockets/assets.rake:66:in `(root)' 
org/jruby/RubyProc.java:270:in `call' 
org/jruby/RubyProc.java:220:in `call' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute' 
org/jruby/RubyArray.java:1612:in `each' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain' 
/home/x/.rvm/rubies/jruby-1.6.5.1/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/actionpack-3.1.1/lib/sprockets/assets.rake:56:in `(root)' 
org/jruby/RubyProc.java:270:in `call' 
org/jruby/RubyProc.java:220:in `call' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute' 
org/jruby/RubyArray.java:1612:in `each' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain' 
/home/x/.rvm/rubies/jruby-1.6.5.1/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level' 
org/jruby/RubyArray.java:1612:in `each' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' 
/home/x/.rvm/gems/jruby-1.6.5.1/gems/rake-0.9.2.2/bin/rake:33:in `(root)' 
org/jruby/RubyKernel.java:1063:in `load' 
/home/x/.rvm/gems/jruby-1.6.5.1/bin/rake:19:in `(root)' 

如果我刪除了jQuery需要app/assets/javascripts/application.js(jQuery和jquery_ujs),預編譯任務成功完成。

我跟蹤的誤差jquery的源文件:

// IE doesn't match non-breaking spaces with \s 
if (rnotwhite.test("\xA0")) { 
    trimLeft = /^[\s\xA0]+/; 
    trimRight = /[\s\xA0]+$/; 
} 

請問\ XA0性格是造成這個錯誤?或者是別的什麼?

謝謝。

+0

我可以通過註釋掉那些有問題的代碼,但知道原因是什麼會很好。 – Garrett

+0

我在jQuery的同一行上有這個錯誤。奇怪的是,部署到我的舞臺環境中,使用相同的資源,相同版本的jRuby,以及其他所有內容(至少應該是!),不會遇到這個問題 - 只有部署到生產才能達到此目的! –

+0

我懷疑這個問題是由於你的/我的暫存/生產服務器上運行的Java的一些設置 - 在相同版本的jRuby上在OS X上運行預編譯沒有任何問題。 –

回答

1

我能夠通過從:uglifier壓縮器​​(默認值)切換到:closure編譯器,在jRuby 1.6.7下使用jQuery 1.7.2進行資產預編譯。 (我也嘗試了:yui編譯器,但它顯然與jRuby不兼容 - 它想使用fork,這是jRuby不想提供的。)