1 minute read

In this blog post I cover the infamous “Invalid US-ASCII character "\xE2" on line 54” error that seems to plague people when trying to serve their sites locally. OK, I actually don’t fix the problem but I create a workaround.

The problem

Have you ever ran into this issue?

Error:  Invalid US-ASCII character "\xE2" on line 54

I ran into this issue when trying to serve my jekyll site locally

$ jekyll serve

And then this happened.

Configuration file: /Users/janmeppe/Github-blog/rainymood.github.io/_config.yml
            Source: /Users/janmeppe/Github-blog/rainymood.github.io
       Destination: /Users/janmeppe/Github-blog/rainymood.github.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
Invalid theme folder: _sass
      Remote Theme: Using theme mmistakes/minimal-mistakes
       Jekyll Feed: Generating feed for posts
   GitHub Metadata: No GitHub API authentication could be found. Some fields may be missing or have incorrect data.
  Conversion error: Jekyll::Converters::Scss encountered an error while converting 'assets/css/main.scss':
                    Invalid US-ASCII character "\xE2" on line 54
jekyll 3.8.5 | Error:  Invalid US-ASCII character "\xE2" on line 54
exit 1

The solution

After scouring the internet trying many solutions such as the solution presented here and this one, I found a very simple solution here that works great!

Create a new file called Rakefile with this content

task :build do
  system "env LANG=\"en_US.UTF-8\" bundle exec jekyll serve"
end

This sets the locale encoding to the correct one and should allow you to serve your site locally, finally!

I spiced mine up a little bit and it looks like this

task :build do
  system "env LANG=\"en_US.UTF-8\" bundle exec jekyll serve -l -o --drafts"
end

The -l flag turns on live reload, which makes the website rebuild automatically when it detects a change. The -o flag opens localhost when serving it and the --drafts flag allows me to create draft posts so that I can preview them locally before pushing them to my blog.

Now you can build the website using

$ rake build

Et voilà!

Configuration file: /Users/janmeppe/Github-blog/rainymood.github.io/_config.yml
            Source: /Users/janmeppe/Github-blog/rainymood.github.io
       Destination: /Users/janmeppe/Github-blog/rainymood.github.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
Invalid theme folder: _sass
      Remote Theme: Using theme mmistakes/minimal-mistakes
       Jekyll Feed: Generating feed for posts
   GitHub Metadata: No GitHub API authentication could be found. Some fields may be missing or have incorrect data.
                    done in 13.275 seconds.
 Auto-regeneration: enabled for '/Users/janmeppe/Github-blog/rainymood.github.io'
    Server address: http://127.0.0.1:4000

Subscribe

Comments