Cloudflare Pages build error migrating from GitHub Pages

Hi guys,

I’m trying to migrate from GitHub pages following the migration guide here.

I setup a ruby environment with the same version of Cloudflare Pages (3.2.2) and I can build everything fine locally, no error, no warnings.

When I try the deploy, I get an error related to the gem jekyll-sass-converter:

12:34:43.151	/opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/runtime.rb:304:in `check_for_activated_spec!': You have already activated jekyll-sass-converter 3.0.0, but your Gemfile requires jekyll-sass-converter 1.5.2. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

If I use bundle exec for the build I get this error:

12:37:08.085	jekyll 3.9.5 | Error:  Invalid US-ASCII character "\xE2" on line 5
12:37:08.086	  Conversion error: Jekyll::Converters::Scss encountered an error while converting 'assets/css/style.scss':
12:37:08.086	                    Invalid US-ASCII character "\xE2" on line 5
12:37:08.086	/opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/jekyll-sass-converter-1.5.2/lib/jekyll/converters/scss.rb:123:in `rescue in convert': Invalid US-ASCII character "\xE2" on line 5 (Jekyll::Converters::Scss::SyntaxError)
12:37:08.086	
12:37:08.087	        raise SyntaxError, "#{e} on line #{e.sass_line}"
12:37:08.087	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I tried to update my Gemfile locking the jekyll-sass-converter gem to a higher version, but I get this error when bundle updating:

Because github-pages >= 178 depends on jekyll-sass-converter = 1.5.2
  and Gemfile depends on github-pages ~> 231,
  jekyll-sass-converter = 1.5.2 is required.
So, because Gemfile depends on jekyll-sass-converter ~> 2.0,
  version solving has failed.

Seems like something’s off or I’m missing it… Do you have any idea?

Thank you very much for your help!

Seems like this issue is related to the encoding and part of an old frozen bug:

Invalid US-ASCII character “\xE2” · Issue #4268 · jekyll/jekyll (github.com)

Adding the following environmental variables fixed the deployment:

  LC_ALL: "C.UTF-8"
  LANG: "en_US.UTF-8"
  LANGUAGE: "en_US.UTF-8"

I ran into a similar error,
above solution to set all three variables in my Cloudflare env solved it, too.

|20:21:40.370|/opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/jekyll-4.3.3/lib/jekyll/url.rb:161:in `encode': "\xE2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)|
| --- | --- |
|20:21:40.371|from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/jekyll-4.3.3/lib/jekyll/url.rb:161:in `unescape_path'|
|20:21:40.371|from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/jekyll-4.3.3/lib/jekyll/static_file.rb:56:in `destination'|
|20:21:40.371|from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/jekyll-4.3.3/lib/jekyll/cleaner.rb:60:in `block (2 levels) in new_files'|
...

I found I can reproduce it locally by running:
LANG=C jekyll build
LC_ALL is not set
LANGUAGE is en_US