Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@import line expected selector or at-rule, but not because of missing semicolon

Tags:

compass-sass

I have this compass error

Line 3: Invalid CSS after "@charset "UTF-8"": expected selector or at-rule, was "@import 'compass';")

The file is just the following. It does not even contain any of my own code

@charset "UTF-8"
@import 'compass';

I know that people say this error occurs when the @import line misses semicolon, but my file has the semicolon.

And the same files (scss and config.rb) can be easily compiled in linux with no problems.


Does anybody know what is wrong?

The configuration which gives error is

Windows 8.1
ruby 2.1.6p336 (2015-04-13 revision 50298) [i386-mingw32]
Compass 1.0.3 (Polaris)
Sass 3.4.16 (Selective Steve)

I tried many combinations

(1)
-------------------
@import 'compass';    
-------------------
// only this line, no @charset line.
// Result: compilation ok, but I need charset because 
// my COMMENTS (yes only comments) have UTF8 chars.

(2)
-------------------
@charset "UTF-8";

@import 'compass';    
-------------------
// semicolon after @charset
// Result: compilation error:
// Invalid CP950 character "\xE2"
// because the @charset line is unrecognised

(3)
// Add this to config.rb
Encoding.default_external = 'utf-8'
// https://stackoverflow.com/a/23338595/2841279
// http://blog.pixelastic.com/2014/09/06/compass-utf-8-encoding-on-windows/
// Result: compilation error: expected selector or
// at-rule, was "@import 'compass';

(4)
// Add this to config.rb
encoding = "utf-8"
// https://stackoverflow.com/a/13987672/2841279
// Result: compilation error: expected selector or
// at-rule, was "@import 'compass';
like image 907
Ka Fai Lo Avatar asked Jul 11 '15 07:07

Ka Fai Lo


3 Answers

Looks like putting that anywhere other than the first line of the page results in that error. Try putting it right at the top and see if it fixes that issue.

like image 64
EnterPassword Avatar answered Oct 23 '22 14:10

EnterPassword


@charset "UTF-8"; is added by the compiler e.g. sass whenever required

like image 1
Anselm Avatar answered Oct 23 '22 16:10

Anselm


this is how it needs to be in order to work

@charset "UTF-8";@import 'compass';
like image 1
Joe Diaz Avatar answered Oct 23 '22 16:10

Joe Diaz