How to deal with _sass converting errors?


#1

This is not the first time I’ve seen this kind of error, but it has been a long time since the last time… I cannot remember the solution, but I can’t forget that it takes always ages to find out what is going on. The two main reasons (AFAIK) are that: 1) I’m using gitlab, and not github (and it takes time to find something about), and 2) that the error happens in an imaginary line which I can’t find…

Here is how I got to the error:

  • created and published (to gitlab pages) a new blog with Minima. It was working both locally and after being published.
  • Minimal Mistakes theme installed and working locally.

Here is the last error I’ve got after pushing:

Destination: public
 Incremental build: disabled. Enable with --incremental
      Generating... 
  Conversion error: Jekyll::Converters::Scss encountered an error while converting 'assets/css/main.scss':
                    Invalid US-ASCII character "\xE2" on line 54
jekyll 3.5.2 | Error:  Invalid US-ASCII character "\xE2" on line 54
ERROR: Job failed: exit code 1

I’ve found some issues about this: both on jekyll’s and minimal mistakes’s repositories, and also at some other places, but they all fall into to different approaches:

  • An US-ASCII invalid character that should be replaced

but which I couldn’t find (neither grepping nor manually checking the files), or:

  • or some locale info (locale-gen en_US.UTF-8 etc) that should be added to docker or maybe .gitlab-ci.yml

and I really don’t have a clue about how/when/where/why…

My main doubt right now is: how to read those error messages about a line that I can’t find (since the it is not compiled yet, and since I couldn’t find anything on _site/ to give me a clue)? But any help on how to solve the issue is appreciated, as well as a better way to rephrase the topic’s title.

Thanks in advance!


#2

Last year I was playing with GL and the ci stuff - I do not remember that much about it, but in my ci file I do have some locale stuff that I had to put in there to get it to work, under script - do you have anything like that in your ci file?

I am not using the awesome MM theme - just my own stuff.

A lot of what I was trying to accomplish had to do with getting a minify script to work as well as pushing to S3 - that is why this is such a long file I think.

Here it is, definitely do not copy it as is, just see if adding the locale stuff (5-6 lines I think) in the same part helps:

image: ruby:2.3
test:
  stage: test
  script:
  - gem install jekyll
  - jekyll build -d test
  artifacts:
    paths:
    - test
  except:
  - master
pages:
  stage: deploy
  script:
  - apt-get update -y
  - apt-get install -y openjdk-7-jre-headless
  - apt-get install -y locales
  - echo "en_US UTF-8" > /etc/locale.gen
  - locale-gen en_US.UTF-8
  - export LANG=en_US.UTF-8
  - export LANGUAGE=en_US:en
  - export LC_ALL=en_US.UTF-8
  - gem install therubyracer
  - gem install reduce
  - gem install jekyll
  - jekyll --version
  - gem install s3_website
  - gem install octopress-autoprefixer
  - jekyll build -d public
  - rake minify
  - s3_website push
  artifacts:
    paths:
    - public
  only:
  - master


#3

Thanks again, @rdyar!

I had the kind of “official” .gitlab-ci.yml for jekyll. And it has only one line on its pages: scripts:, which is: - bundle exec jekyll build -d public.

On the issues mentioned on the first post, there are some mentions to adding something about the locale (such as - export LANG=en_US.UTF-8), but I wasn’t sure at this should be on the .gitlab-ci.yml, and even if it should be there, I didn’t know where exactly. However, thanks to your .gitlab-ci.yml it is working now.

I took the first 8 lines of your pages: script: section, and added them before the - bundle exec jekyll build -d public.

Here is the whole file for reference (in case anyone needs it):

image: ruby:2.3

variables:
  JEKYLL_ENV: production

before_script:
  - bundle install

test:
  stage: test
  script:
  - bundle exec jekyll build -d test
  artifacts:
    paths:
    - test
  except:
  - master

pages:
  stage: deploy
  script:
  - apt-get update -y
  - apt-get install -y openjdk-7-jre-headless
  - apt-get install -y locales
  - echo "en_US UTF-8" > /etc/locale.gen
  - locale-gen en_US.UTF-8
  - export LANG=en_US.UTF-8
  - export LANGUAGE=en_US:en
  - export LC_ALL=en_US.UTF-8
  - bundle exec jekyll build -d public
  artifacts:
    paths:
    - public
  only:
  - master

I’m not sure if this is most effective way to solve the problem, but it does work (but any feedback is welcome). :slight_smile:

If anyone has any idea on how to properly understanding these “_sass” erros, I would be really thankful. And any suggestion to a better title to this topic would be appreciated as well.


#4

this line installs java which you should not need so you can probably remove it and it will go a little faster and should still work properly. I was installing java so that the s3_website gem would work.

Glad it worked!

as for where the error is, from what I saw reading different issues it is probably something in a comment in the sass files. As long as the locale is set I don’t think there is an actual error.


#5

Thanks!

In this case, it would be better off with another erro message. Anyway, thanks again . (:


#6

Yeah the apt-get install -y openjdk-7-jre-headless isn’t needed for Jekyll on GitLab. I have found the most efficient way to get GitLab CI to build the Jekyll site is with the following .gitlab-ci.yml file.

image: ruby:2.3

cache:
  paths:
  - vendor/

before_script:
  - apt-get update -y
  - apt-get install -y locales
  - echo "en_US UTF-8" > /etc/locale.gen
  - locale-gen en_US.UTF-8
  - export LANG=en_US.UTF-8
  - export LANGUAGE=en_US:en
  - export LC_ALL=en_US.UTF-8
  - gem install jekyll bundler --install-dir vendor/ruby/2.3.0
  - gem install sass --no-user-install --install-dir vendor/ruby/2.3.0
  - bundle install --path vendor

variables:
  JEKYLL_ENV: production

pages:
  stage: deploy
  script:
  - bundle exec jekyll build -d public
  artifacts:
    paths:
    - public
  only:
  - master

test:
  stage: test
  script:
  - bundle exec jekyll build -d test
  artifacts:
    paths:
    - test
  except:
  - master

Note that I am installing all the Gems in the locally configured ./vendor/ folder. This just keeps everything neat and tidy. I’ve also added a before_script: YAML setting and moved all the installs to this part of the config file. This way, all the dependencies are installed before you run any of the deploy methods.

It took me many many hours to get GitLab CI to build my old GitHub Pages website so I hope that this config file helps other people too!