Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails precompile error in CSS

Invalid CSS after "}": expected selector or at-rule, was "}"
  (in /home/test/www/dispatch/app/assets/stylesheets/application.css)
(sass):364

The above error is what is occurring in my precompile and I'm unable to find the problem. I've tried renaming the file to application.css.scss and I get the same error, with a different line number :405

The thing that has me stumped is that this file only contains 159 lines so I'm not sure where that line number is coming from.

I'm precompiling on my local machine because last night this error occurred in an attempt at a production migration.

like image 327
user1214966 Avatar asked Mar 28 '12 16:03

user1214966


3 Answers

If its your application.css then it would compile all your css to that file, so there's a chance that the problem isn't in that file itself, but in a file it's compiling into it. Check your code for a missing semicolon.

like image 52
Donavan White Avatar answered Nov 18 '22 05:11

Donavan White


I've hated these errors because they don't provide any stack trace. So once this happens, you are forced to spend hours seaching for that semi-colon. I hope Rails' guys will fix this soon.

Meanwhile, I've found an excellent way to detect such errors, by passing them through your CSS Compiler or compressor. In my app, we use SASS, so I can call:

sass --style compressed --scss -C your_problematic_file.css

That'll tell you if there's any error with that file, and the line number. You'll need to run this on every CSS file that can possibly be a culprit.

In my case, it was an extra } around media queries.

like image 22
Kazim Zaidi Avatar answered Nov 18 '22 04:11

Kazim Zaidi


I agree with @Digi_Cazter. But the same error may happen because of putting invalid brackets like

.someclass{
  property: value;
}}
like image 2
Jyothu Avatar answered Nov 18 '22 04:11

Jyothu