当我尝试预编译资产时出现此错误。我是Rails的新手,处理资产管道让我想把头发拉出来,哈哈。我用ruby 1.9.2-p320或ruby 1.9.3-p448尝试了同样的错误。使用Rails 3.2.13。对我来说,困难的部分是查看错误输出并了解查找错误的位置。关于如何做到,我没有看到很多解释。我是否更正错误是在rails帮助文件中?如果是的话,那是哪里?
Here is the rake assets:precompile --trace results:
ruby-1.9.2-p320@stacy1 MARKs-MacBook-Air:stacy1 mark$ rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/mark/.rvm/rubies/ruby-1.9.2-p320/bin/ruby /Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/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!
undefined method `[]' for nil:NilClass
(in /Users/mark/Documents/projects/hosting/stacy1/app/assets/stylesheets/application.css.scss)
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-rails-3.2.6/lib/sass/rails/helpers.rb:32:in `resolver'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-rails-3.2.6/lib/sass/rails/helpers.rb:25:in `font_url'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/script/funcall.rb:112:in `_perform'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/script/node.rb:40:in `perform'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:298:in `visit_prop'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/base.rb:37:in `visit'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:100:in `visit'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/base.rb:53:in `map'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:356:in `visit_directive'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/base.rb:37:in `visit'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:100:in `visit'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/base.rb:53:in `map'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:128:in `visit_root'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/base.rb:37:in `visit'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:100:in `visit'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/visitors/perform.rb:7:in `visit'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/tree/root_node.rb:20:in `render'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/engine.rb:315:in `_render'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-3.2.12/lib/sass/engine.rb:262:in `render'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sass-rails-3.2.6/lib/sass/rails/compressor.rb:12:in `compress'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/actionpack-3.2.13/lib/sprockets/compressors.rb:74:in `compress'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/processing.rb:243:in `block in css_compressor='
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `call'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `evaluate'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:26:in `initialize'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `build_asset'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:19:in `block in compile'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:18:in `compile'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:56:in `internal_precompile'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/mark/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/mark/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/bin/rake:23:in `load'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/Users/mark/.rvm/rubies/ruby-1.9.2-p...]
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/file_utils.rb:55:in `block in create_shell_runner'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `call'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `sh'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `sh'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/file_utils.rb:82:in `ruby'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `ruby'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/mark/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/bin/rake:23:in `load'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/bin/rake:23:in `<main>'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/bin/ruby_executable_hooks:15:in `eval'
/Users/mark/.rvm/gems/ruby-1.9.2-p320@stacy1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => assets:precompile`enter code here`
这是application.css.scss文件:
/*
*= require_self
*= require_tree .
*/
答案 0 :(得分:1)
在.css文件中使用image-url(/path/to/file.png),将其更改为url(/assets/path/to/file.png)
答案 1 :(得分:0)
我通过使用ruby 2.0.0和rails 4.0将我的开发转移到RVM来解决了这个问题。之后一切都很好。我慢慢地将我的文件添加到新配置中并继续运行预编译以确保它在每个步骤中都能正常工作。谢谢大家的帮助。