Invalid US-ASCII character Error when compiling Jekyll
February 13, 2019
When compiling TMB for the first time on our production server we ran into a strange error we’d never seen before:
Examining our main sass file didn’t lead us anywhere either:
The charset was properly set in the sass file, grepping for invalid ASCII characters revealed nothing, and systematically stepping through and deleting portions of the file and re-compiling revealed that stripping the dashes in the YAML frontmatter would remove the error1, but also prevented Jekyll from properly compiling the sass file into css (and thus breaking the site).
There are several threads out there on this issue but none of the solutions listed worked for us.
It turns out the solution was somewhat simpler (and totally unrelated to Jekyll/Sass) - we hadn’t set the locale properly on our server. Bash was even warning us every time we SSH’d in, but we’d just been glossing over it.
This can be done temporarily from the command line for each session:
export LANG=en_US.UTF-8
Or properly by setting the appropriate environment variables:
vi /etc/environment
then adding these lines:
Problem solved.
-
Not to mention that yes, the dashes were proper ASCII dashes and file encoding itself was set properly so that was equally confusing. ↩