Invalid US-ASCII character using SASS

1.3k Views Asked by At

I'm using grunt, grunt-contrib-sass, and angular material. After adding in angular material, the build began failing in the CI process (BitBucket Pipelines). The error is:

Invalid US-ASCII character "\xE2" online 4242 of bower_components/angular-material/angular-material.scss

Everything I've read about solving this involves setting the encoding at the top of the SASS file, but since it's installed via bower during the build process, that's not plausible. I did try adding this to the top of my main scss file where angular material is imported, but this did not work.

I'm using a PC and it works fine locally. I'm using a docker image starefossen/ruby-node:latest for CI which is where it fails. Here's the build script in pipelines:

npm install npm install -g bower bower install --allow-root npm install -g grunt-cli gem install sass grunt test grunt build

This installs sass 3.4.22.

3

There are 3 best solutions below

3
rrd On

Are you using a Mac? What version of Sass are you using?

Also found this, might help:

Just add this line to top of config.rb
Encoding.default_external = "utf-8"
1
JohanSellberg On

Changing file encoding in one way or another could prob work.

You could also check your material.scss (On line 4242 it looks like) or the code you added and replace suspicious characters..

\xe2 is normally a character like , or - but not the same as the ascii entered by keyboard. often these enters your code if you copy-paste from the web.

in your newly added code replace non-letter characters with ones typed by keyboard and it should work.

2
mrmoree On

As rrd wrote:

Are you using a Mac? What version of Sass are you using?

Also found this, might help:

Just add this line to top of config.rb Encoding.default_external = "utf-8"

I ran into the same charset problem.

Especially on OSX there seams to be a problem with ruby Encoding Settings.

I fixed it creating a config.rb file in the main project directory to tell ruby explicitly which charset encoding it should use. Since sass and compass depend on ruby, chances good that this will fix your problems.

Encoding.default_external = 'utf-8'