为什么' rake资产:预编译'给出NoMethodError:nil的未定义方法[]:NilClass&#39 ;?

时间:2015-04-20 21:55:12

标签: ruby-on-rails

我正在尝试使用Capistrano部署项目,但我收到了此错误。

当我直接在服务器上运行命令时,会发生同样的事情。以下是/opt/rbenv/shims/bundle exec rake assets:precompile --trace

的输出
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
[snip]/shared/bundle/ruby/2.2.0/gems/less-rails-2.6.0/lib/less/rails/template_handlers.rb:37:in `config_paths'
[snip]/shared/bundle/ruby/2.2.0/gems/less-rails-2.6.0/lib/less/rails/template_handlers.rb:26:in `config_to_less_parser_options'
[snip]/shared/bundle/ruby/2.2.0/gems/less-rails-2.6.0/lib/less/rails/template_handlers.rb:17:in `evaluate'
[snip]/shared/bundle/ruby/2.2.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/legacy_tilt_processor.rb:25:in `call'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/processor_utils.rb:73:in `call_processor'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/processor_utils.rb:55:in `block in call_processors'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/processor_utils.rb:54:in `reverse_each'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/processor_utils.rb:54:in `call_processors'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/loader.rb:103:in `load_asset_by_uri'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/loader.rb:40:in `block in load'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/loader.rb:170:in `fetch_asset_from_dependency_cache'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/loader.rb:33:in `load'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/cached_environment.rb:47:in `yield'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/cached_environment.rb:47:in `load'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/bundle.rb:23:in `block in call'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/utils.rb:183:in `dfs'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/bundle.rb:24:in `call'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/processor_utils.rb:73:in `call_processor'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/processor_utils.rb:55:in `block in call_processors'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/processor_utils.rb:54:in `reverse_each'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/processor_utils.rb:54:in `call_processors'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/loader.rb:103:in `load_asset_by_uri'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/loader.rb:40:in `block in load'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/loader.rb:170:in `fetch_asset_from_dependency_cache'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/loader.rb:33:in `load'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/cached_environment.rb:47:in `yield'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/cached_environment.rb:47:in `load'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/base.rb:63:in `find_asset'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/base.rb:70:in `find_all_linked_assets'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/manifest.rb:138:in `block in find'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/path_utils.rb:223:in `block in stat_tree'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/path_utils.rb:207:in `block in stat_directory'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/path_utils.rb:204:in `each'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/path_utils.rb:204:in `stat_directory'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/path_utils.rb:222:in `stat_tree'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/legacy.rb:105:in `each'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/legacy.rb:105:in `block in logical_paths'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/legacy.rb:104:in `each'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/legacy.rb:104:in `logical_paths'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/manifest.rb:136:in `find'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/sprockets/manifest.rb:162:in `compile'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.1/lib/rake/sprocketstask.rb:147:in `with_logger'
[snip]/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/opt/rbenv/versions/2.2.0/bin/rake:33:in `<main>'
Tasks: TOP => assets:precompile

我试图通过回溯,但我无法找到触及我的代码的任何地方。

导致此错误的原因是什么?

1 个答案:

答案 0 :(得分:5)

我找到this answer,所以我决定再次尝试升级我的宝石。我将less-rails2.6.0升级为2.7.0,这似乎解决了这个问题。