0

我为我的 rails 应用程序购买了一个主题,不幸的是它有很多 css 错误。当我尝试预编译资产时,会弹出此错误

Invalid CSS after "  margin-top:": expected expression (e.g. 1px, bold), was "}"
  (in /home/ubuntu/rails_app/app/assets/stylesheets/application.css)
(sass):6109
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:1146:in `expected'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/script/lexer.rb:199:in `expected!'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/script/parser.rb:471:in `assert_expr'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/script/parser.rb:49:in `parse'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:1022:in `sass_script'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:882:in `value!'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:859:in `declaration'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:582:in `block in declaration_or_ruleset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:1122:in `call'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:1122:in `rethrow'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:592:in `declaration_or_ruleset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:554:in `block_child'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:546:in `block_contents'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:535:in `block'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:529:in `ruleset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:553:in `block_child'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:546:in `block_contents'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:82:in `stylesheet'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/scss/parser.rb:27:in `parse'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/engine.rb:342:in `_to_tree'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/engine.rb:315:in `_render'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.9/lib/sass/engine.rb:262:in `render'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sass-rails-3.2.6/lib/sass/rails/compressor.rb:16:in `compress'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/sprockets/compressors.rb:74:in `compress'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/processing.rb:243:in `block in css_compressor='
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `call'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `evaluate'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:26:in `initialize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:19:in `block in compile'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:18:in `compile'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:56:in `internal_precompile'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/bin/rake:23:in `load'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/home/ubuntu/.rvm/rubies/ruby-2.0.0-p0/bi...]
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `call'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `sh'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:37:in `sh'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/file_utils.rb:80:in `ruby'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:37:in `ruby'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/bin/rake:23:in `load'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/bin/rake:23:in `<main>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `eval'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => assets:precompile

我应该如何准确地找到发生错误的 css 文件的哪一行,因为在 css 文件margin-top中使用了超过 500 次。

谢谢

4

1 回答 1

0

我会对文件进行 ack-grep 并获取 margin-top 的所有位置。

您正在寻找的是没有与之关联的表达式的 margin-top 声明。应该很清楚那里什么都没有,但话说回来,这可能只是一个非常混乱的文件并且难以阅读。

编辑:

ack-grep margin-top: .

只会在目录中寻找所有出现的 margin-top:。如果您想使用任何其他正则表达式来查找更具体的内容,您可以使用 ack-grep 来完成。

于 2013-08-09T18:18:51.920 回答