Reputation: 9316
I have a rails app that is getting a weird error when I try to run rake assets:precompile
. It looks like this:
rake aborted!
Invalid US-ASCII character "\xE2"
(in /Users/lee/Code/draper/app/assets/stylesheets/application.css.scss)
(sass):9
I'm not sure where an invalid character might have slipped into my code. I'm using Twitter Bootstrap (boostrap-sass gem) and my bootstrap_and_overrides.css.scss
file seems to be the culprit. I've already tried recreating this file from scratch in text mate to get any weird characters out and that didn't work. The only thing that seems to work is adding this to the top of my bootstrap_and_overrides.css.scss
:
@charset "UTF-8";
That allows me to run rake assets:precompile and then deploy to Heroku, but that seems like a hack and a dirty fix. I can deploy other apps to Heroku that use bootstrap-sass just fine and Heroku is able to run rake assets:precompile when deploying. Right now the only way to get around it is to include the @charset "UTF-8";
and then run rake assets:precompile
locally before deploying to Heroku so that it skips that step during deployment.
I can't figure out where I went wrong with this.
Upvotes: 3
Views: 3661
Reputation: 10473
Check your CSS files. The character \xE2
usually correlates to a double quote character that's not part of the ASCII character set. In an editor they often look like a more slanted double quote. “mystring”
vs "mystring"
Using the @charset
declaration isn't a hack, but if you don't need to be using a UTF-8 character, you're probably better off removing it.
Upvotes: 5
Reputation: 140230
Declaring correct encoding for your file is not a hack, a text file always needs a declared encoding and physical encoding. Anyways, you could just remove all non-ascii characters with iconv on the file:
iconv -t ASCII//IGNORE -f UTF8 < application.css.scss > application.css.scss.ascii
Then the resulting file will work with virtually any encoding.
Upvotes: 2