jekyll: Invalid US-ASCII character "\xE2"
There’s quite a few pages on the Internet talking about this problem with Ruby but none of the solutions seem to work with Jekyll. Ultimately, I’m trying to build a Jekyll site in a Docker container and I’ve tried setting @charset
as well as all the locale
ENV variables. is there something I can set in _config.yml
to solve this?
Configuration file: /www/_config.yml
Source: /www
Destination: /www/_site
Incremental build: enabled
Generating...
Conversion error: Jekyll::Converters::Scss encountered an error while converting 'assets/css/styles.scss':
Invalid US-ASCII character "\xE2" on line 3
/usr/local/bundle/gems/jekyll-sass-converter-1.3.0/lib/jekyll/converters/scss.rb:97:in `rescue in convert': Invalid US-ASCII character "\xE2" on line 3 (Jekyll::Converters::Scss::SyntaxError)
from /usr/local/bundle/gems/jekyll-sass-converter-1.3.0/lib/jekyll/converters/scss.rb:95:in `convert'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/convertible.rb:67:in `block in transform'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/convertible.rb:65:in `each'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/convertible.rb:65:in `reduce'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/convertible.rb:65:in `transform'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/convertible.rb:249:in `do_layout'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/page.rb:122:in `render'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/site.rb:302:in `block in render'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/site.rb:301:in `each'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/site.rb:301:in `render'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/site.rb:55:in `process'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/command.rb:28:in `process_site'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/commands/build.rb:58:in `build'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/commands/build.rb:34:in `process'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
from /usr/local/bundle/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `call'
from /usr/local/bundle/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `block in execute'
from /usr/local/bundle/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `each'
from /usr/local/bundle/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `execute'
from /usr/local/bundle/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in `go'
from /usr/local/bundle/gems/mercenary-0.3.5/lib/mercenary.rb:19:in `program'
from /usr/local/bundle/bundler/gems/jekyll-43a28aed967b/bin/jekyll:20:in `<top (required)>'
from /usr/local/bundle/bin/jekyll:16:in `load'
from /usr/local/bundle/bin/jekyll:16:in `<main>'
rake aborted!
Command failed with status (1): [bundle exec jekyll build --trace...]
/www/Rakefile:295:in `jekyll'
/www/Rakefile:97:in `block in <top (required)>'
Tasks: TOP => build
(See full trace by running task with --trace)
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 31 (11 by maintainers)
Commits related to this issue
- feat(docker): configure UTF-8 locales Close: #2 Related: jekyll/jekyll#4268 — committed to Starefossen/docker-github-pages by deleted user 8 years ago
- Fixed charset problem https://github.com/jekyll/jekyll/issues/4268 — committed to Praqma/docker-geb by illus0r 8 years ago
- fix container locale issue https://github.com/jekyll/jekyll/issues/4268#issuecomment-167406574 — committed to ee491f/course-material by zhaol 7 years ago
- Set UTF-8 environment Suggestion from https://github.com/jekyll/jekyll/issues/4268#issuecomment-167406574 — committed to dltj/dltj-blog by dltj 6 years ago
Thanks for the reply @parkr but after searching, I manage to fix it and I’m sharing my solution. I found out that the docker container is using a different charset or locale so you have to set it in you docker file.
I manage to fix mine by adding this on my Dockerfile. No need to upgrade to sass converter 1.4.0.
Hope this helps everyone!
My jekyll build is being done by AWS CodeBuild, and I found I needed to add these lines to the
buildspec.yml
file:I also ran into this problem, and found this thread very helpful but it didn’t cover my case. Hopefully this helps the next person.
For me, setting
LANG=en_US.UTF-8
didn’t work because the locale hadn’t been generated on my system and it was falling back toLANG=C
which caused the error. Additionally, the problematic character I had was an en-dash (\xe2\x80\x93
) not actuallyâ
(\xe2
). The fix was to generate a UTF-8 locale and set it. Instructions tested on Arch Linux.locale -a
/etc/locale.gen
and runsudo locale-gen
/etc/locale.conf
and log in again for it to take effectexport LANG=en_US.UTF-8
set -xg LANG en_US.UTF-8
For the record, I found this great one-liner for finding non-ASCII characters:
If anyone is getting this on GitLab, add the list on the above ^ https://github.com/jekyll/jekyll/issues/4268#issuecomment-357095209
just put this in a
before_script:
before everything elseJust for the future reference:
I originally turned off
Set locale environment variables on startup
in my OSX Terminal preference due to other reasons. The error is gone if I check this checkbox.I’m also having this issue. No problem if hosted via GitHub pages, but when I use docker on my own laptop or server, it has this issue.
The problem is the
above the scss file. If you remove this, there would be no error but the scss will not be converted. Still don’t know how to fix this.
For Jekyll on Gitlab, alternative to @IotaSpencer’s solution is adding them in variables, like:
I get this problem when building a Jekyll site with
wercker
and there’s Unicode in the SASS. Removing the UTF-8 characters or using @AngeloAballe’s solution works.I ran into this issue as well while trying to build my project over at GitLab. What was causing the issue was this bit of code:
The
“
and”
were the culprits. Changing them to be the hex value fixed the issue.@AngeloAballe The YAML front matter (two lines of
---
) are not the problem – they merely tell Jekyll to convert the SCSS into CSS. Have you tried outside of Docker? See Dalan’s comment about finding these characters:Happened again with the
_config.yml
change. Iack
’d through my repo and couldn’t find any of those and don’t see why I would have any non-English characters in the imports. Also, it says it’s occurring here in thestyles.scss
file:assets/css/styles.scss