A few months ago I was working on building out a Jekyll based website for a new project that I am working on and I ran into an issue with using CodeBuild to build the website and deploy it. Every time that it tried to build the site, I would get the following error:

Invalid US-ASCII character “\xE2” on line

After doing some research, I found that that docker container that I use in CodeBuild (aws/codebuild/ruby:2.3.1) defaults to POSIX and the Troubleshooting AWS CodeBuild suggested that I add the following to my buildspec.yml file:

    - export LC_ALL="en_US.UTF-8"
    - locale-gen en_US en_US.UTF-8
    - dpkg-reconfigure locales

I tried about a thousand variations of this to try and get the website deployed and after while I just switch the theme to something minimal to get it up and running and basically punted on figuring out why it didn’t work.

I returned to the site this week to make some updated and decided that I needed to fix the issue for good. After putting the new theme in place I immediately started having the issue and began the troubleshooting process all over again. After about two hours of searching and testing possible solutions, I came across a blog bost by Neil Millard about moving WordPress to Jekyll. Instead of putting in the pre_build commands as mentioned on the troubleshooting guide, Neil suggested putting in some environment_variables instead:

    LC_ALL: C.UTF-8
    ENV LANG: en_US.UTF-8

I updated my buildspec.yml file and the site started to build successfully. WOOT!