2016-11-21 57 views
0

有了這個HAML部分意外縮進錯誤軌道5.0

!!! 
%html 
    %head 
     %title=document_title 
     = favicon_link_tag 'logo16.png' 
     %meta{content: form_authenticity_token, name: "csrf-token"}= '' 
     ... 

我得到的錯誤

SyntaxError: [stdin]:68:1: unexpected indentation 

所以我打得有點用錯Identation;然後我得到其他,但糾正錯誤

Inconsistent indentation: "\t\t " used for indentation, but the rest of the document was indented using 1 tab. 
Inconsistent indentation: "\t " used for indentation, but the rest of the document was indented using 1 tab. 
Illegal nesting: content can't be both given on the same line as %title and nested within it. 

和堆棧跟蹤看起來像

app/views/layouts/page_print.html.haml:5 
haml (4.0.7) lib/haml/parser.rb:174:in `block in tabs' 

但與unexpected Indentation我得到一個有趣的堆棧 - 什麼是coffee_script有?:

compile (C:\Users\halfbit\AppData\Local\Temp\execjs20161121-7752-txwa8bjs:6692:19) 
eval (<anonymous>:1:10) 
C:\Users\halfbit\AppData\Local\Temp\execjs20161121-7752-txwa8bjs:6703:8 
C:\Users\halfbit\AppData\Local\Temp\execjs20161121-7752-txwa8bjs:6709:14 
require./helpers.exports (C:\Users\halfbit\AppData\Local\Temp\execjs20161121-7752-txwa8bjs:1:102) 
Object.<anonymous> (C:\Users\halfbit\AppData\Local\Temp\execjs20161121-7752-txwa8bjs:1:120) 
Module._compile (module.js:409:26) 
Object.Module._extensions..js (module.js:416:10) 
Module.load (module.js:343:32) 
Function.Module._load (module.js:300:12) 
Function.Module.runMain (module.js:441:10) 
startup (node.js:139:18) 
node.js:968:3 
execjs (2.7.0) lib/execjs/external_runtime.rb:39:in `exec' 
execjs (2.7.0) lib/execjs/external_runtime.rb:21:in `eval' 
execjs (2.7.0) lib/execjs/external_runtime.rb:46:in `call' 
coffee-script (2.4.1) lib/coffee_script.rb:78:in `compile' 
sprockets (3.7.0) lib/sprockets/coffee_script_processor.rb:21:in `block in call' 
sprockets (3.7.0) lib/sprockets/cache.rb:85:in `fetch' 
sprockets (3.7.0) lib/sprockets/coffee_script_processor.rb:20:in `call' 
sprockets (3.7.0) lib/sprockets/processor_utils.rb:75:in `call_processor' 
sprockets (3.7.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors' 
sprockets (3.7.0) lib/sprockets/processor_utils.rb:56:in `reverse_each' 
sprockets (3.7.0) lib/sprockets/processor_utils.rb:56:in `call_processors' 
sprockets (3.7.0) lib/sprockets/loader.rb:134:in `load_from_unloaded' 
sprockets (3.7.0) lib/sprockets/loader.rb:60:in `block in load' 
sprockets (3.7.0) lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache' 
sprockets (3.7.0) lib/sprockets/loader.rb:44:in `load' 
sprockets (3.7.0) lib/sprockets/cached_environment.rb:20:in `block in initialize' 
sprockets (3.7.0) lib/sprockets/cached_environment.rb:47:in `load' 
sprockets (3.7.0) lib/sprockets/bundle.rb:23:in `block in call' 
sprockets (3.7.0) lib/sprockets/utils.rb:196:in `dfs' 
sprockets (3.7.0) lib/sprockets/bundle.rb:24:in `call' 
sprockets (3.7.0) lib/sprockets/processor_utils.rb:75:in `call_processor' 
sprockets (3.7.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors' 
sprockets (3.7.0) lib/sprockets/processor_utils.rb:56:in `reverse_each' 
sprockets (3.7.0) lib/sprockets/processor_utils.rb:56:in `call_processors' 
sprockets (3.7.0) lib/sprockets/loader.rb:134:in `load_from_unloaded' 
sprockets (3.7.0) lib/sprockets/loader.rb:60:in `block in load' 
sprockets (3.7.0) lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache' 
sprockets (3.7.0) lib/sprockets/loader.rb:44:in `load' 
sprockets (3.7.0) lib/sprockets/cached_environment.rb:20:in `block in initialize' 
sprockets (3.7.0) lib/sprockets/cached_environment.rb:47:in `load' 
sprockets (3.7.0) lib/sprockets/base.rb:66:in `find_asset' 
sprockets (3.7.0) lib/sprockets/base.rb:73:in `find_all_linked_assets' 
sprockets (3.7.0) lib/sprockets/manifest.rb:142:in `block in find' 
sprockets (3.7.0) lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths' 
sprockets (3.7.0) lib/sprockets/path_utils.rb:228:in `block in stat_tree' 
sprockets (3.7.0) lib/sprockets/path_utils.rb:212:in `block in stat_directory' 
sprockets (3.7.0) lib/sprockets/path_utils.rb:209:in `each' 
sprockets (3.7.0) lib/sprockets/path_utils.rb:209:in `stat_directory' 
sprockets (3.7.0) lib/sprockets/path_utils.rb:227:in `stat_tree' 
sprockets (3.7.0) lib/sprockets/legacy.rb:105:in `each' 
sprockets (3.7.0) lib/sprockets/legacy.rb:105:in `block in logical_paths' 
sprockets (3.7.0) lib/sprockets/legacy.rb:104:in `each' 
sprockets (3.7.0) lib/sprockets/legacy.rb:104:in `logical_paths' 
sprockets (3.7.0) lib/sprockets/manifest.rb:140:in `find' 
sprockets-rails (3.2.0) lib/sprockets/railtie.rb:50:in `each' 
sprockets-rails (3.2.0) lib/sprockets/railtie.rb:50:in `map' 
sprockets-rails (3.2.0) lib/sprockets/railtie.rb:50:in `precompiled_assets' 
sprockets-rails (3.2.0) lib/sprockets/railtie.rb:35:in `asset_precompiled?' 
sprockets-rails (3.2.0) lib/sprockets/railtie.rb:251:in `block (3 levels) in <class:Railtie>' 
sprockets-rails (3.2.0) lib/sprockets/rails/helper.rb:359:in `precompiled?' 
sprockets-rails (3.2.0) lib/sprockets/rails/helper.rb:363:in `raise_unless_precompiled_asset' 
sprockets-rails (3.2.0) lib/sprockets/rails/helper.rb:337:in `digest_path' 
sprockets-rails (3.2.0) lib/sprockets/rails/helper.rb:325:in `asset_path' 
sprockets-rails (3.2.0) lib/sprockets/rails/helper.rb:102:in `block in resolve_asset_path' 
sprockets-rails (3.2.0) lib/sprockets/rails/helper.rb:242:in `block in resolve_asset' 
sprockets-rails (3.2.0) lib/sprockets/rails/helper.rb:241:in `each' 
sprockets-rails (3.2.0) lib/sprockets/rails/helper.rb:241:in `detect' 
sprockets-rails (3.2.0) lib/sprockets/rails/helper.rb:241:in `resolve_asset' 
sprockets-rails (3.2.0) lib/sprockets/rails/helper.rb:101:in `resolve_asset_path' 
sprockets-rails (3.2.0) lib/sprockets/rails/helper.rb:79:in `compute_asset_path' 
actionview (5.0.0.1) lib/action_view/helpers/asset_url_helper.rb:144:in `asset_path' 
actionview (5.0.0.1) lib/action_view/helpers/asset_url_helper.rb:311:in `image_path' 
actionview (5.0.0.1) lib/action_view/helpers/asset_tag_helper.rb:176:in `favicon_link_tag' 
app/views/layouts/page_print.html.haml:5:in `_app_views_layouts_page_print_html_haml___1809589845_126062940'  

評論

#= favicon_link_tag 'logo16.png' 

無錯

有什麼想法?

回答

1

我做到了,我再次調試Rails - 我討厭這樣做。

的 「解決方案」 或更好的解釋是:

1.) Sprockets behaves completely different in Rails 5.0 that in Rails 3.2 
2.) Sprockets reads and caches the whole assets path with first touch (favicon in this case) 
3.) As far as I can see Sprockets tries to (coffee-) compile manifest.js (?) 
4.) Any compile error is catched (rescued) to late (I would say in HAML in this case) 
5.) Its therefor extremely misleading to get a - coffeescript indentation error pointing to .HAML or .RB file 

我做了什麼?

Sprockes::path_utlis我改變/添加了一個開始/救援:

# Public: Stat all the files under a directory. 
# 
# dir - A String directory 
# 
# Returns an Enumerator of [path, stat]. 
def stat_directory(dir) 
    return to_enum(__method__, dir) unless block_given? 

    self.entries(dir).each do |entry| 
    path = File.join(dir, entry) 
    # puts path.to_s 
    begin 
    if stat = self.stat(path) 
     yield path, stat 
    end 
    rescue => e 
     puts "error #{e} in: "+path 
    end 
    end  

我得到的輸出:

error SyntaxError: [stdin]:68:1: unexpected indentation in: C:/rbstart/app/assets/javascripts/application.js 
error Undefined variable: "$std_width". in: C:/rbstart/app/assets/stylesheets/application.css 

由於緩存錯誤並不總是重現。

+0

哈,所以它_was_ indentation錯誤一直:)但是,偉大的工作! –

+0

但它是一個解釋,而不是解決方案,我認爲_this是一個rails bug_,所以放在哪裏? – halfbit

+0

嘗試在https://github.com/rails/rails上發佈問題到rails的回購站 –