Fixing locale errors with Jekyll plugins on Linux

Posted on .

I've been working on setting up my blog in a way that makes it possible for me to edit and update this website from anywhere. Jekyll makes it easy to create a website that's fully portable by not working with a database, which makes it easy to just push and pull your data from Git, but until a few days ago I just compiled this website on my laptop. This works nice enough, but I have to rely on a traditional computer to do the updates.

To counter this, I've decided to move the build process to a VPS, so I can just build the website with a simple command over SSH, on any device that can remotely log in to this server.

Jekyll is nowadays a pretty well documented framework, and installing it to my Ubuntu 16.04 server was as easy as following the steps from the Jekyll website.

Unfortunately, running the jekyll build or jekyll serve command resulted in a mysterious error:

Error: \xE6 Code: US-ASCII

I noticed that this is the unicode character for the æ ligature, and I started looking for this character in my files to replace it with an HTML entity. I didn't find the character in any of my files (not even in the exported site on my laptop), so this didn't help.

I then tried to create a new jekyll site with the make command, and this website worked perfectly right away. Strange.

I then tried to add the posts from my website to the newly created site, and those also generated on the first try.

I found that the only difference between my site and the new site were that I used a few plugins to help me do some basic tasks (like creating a sitemap, for example). This resulted in discovering that the jekyl-autoprefixer plugin was the cause of the error.

This is an important plugin for me as I'm using flex and (more importantly) grid in my css, technologies that are not yet fully baked in all browsers, so they often need browser specific fallbacks which are automatically generated by autoprefixer.

I then found a blog post by Holly Becker, in which she solved a similar issue. She described that this problem was fixed by setting the Lang and Language variables to en_US.UTF-8 so Ruby (the environment that Jekyll uses) doesn't fall back to an incompatible language. This didn't solve it for me, but the error was similar enough to my issue that I felt that I was looking in the right direction at least.

While searching around I stumbled on a question on StackOverflow that mentioned the same solution, but with a few variables added. And voila: adding LC_ALL to en_US.UTF-8 solved the issue:

export LC_ALL=en_US.UTF-8

I suspect that it's also perfectly possible to change en_US.UTF-8 to your preferred language, given that it's unicode compliant. The default charset of the locale is (if I understand it correctly) set to ASCII, which does not have the æ character available. This issue is probably not only related to that character, but the unicode charset is large enough to account for most non-ASCII characters.