carpentries / styles

Styles for The Carpentries lessons. No README to avoid merge conflicts with lessons. Demo 👇
https://carpentries.github.io/lesson-example
Other
84 stars 94 forks source link

Encoding error when trying to serve a jekyll project #629

Closed GuillermoFidalgo closed 2 years ago

GuillermoFidalgo commented 2 years ago

Hello, I'm having an issue when trying to serve a project (In my case it's https://github.com/GuillermoFidalgo/hsf-training-matplotlib) I get the following

guillermofidalgo@Guillermos-MacBook-Pro hsf-training-matplotlib % bundle exec jekyll serve
Configuration file: /Users/guillermofidalgo/Documents/Websites/hsf-training-matplotlib/_config.yml
            Source: /Users/guillermofidalgo/Documents/Websites/hsf-training-matplotlib
       Destination: /Users/guillermofidalgo/Documents/Websites/hsf-training-matplotlib/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
  Conversion error: Jekyll::Converters::Scss encountered an error while converting 'assets/css/style.scss':
                    Invalid US-ASCII character "\xE2" on line 5
jekyll 3.9.0 | Error:  Invalid US-ASCII character "\xE2" on line 5
/Users/guillermofidalgo/Documents/Websites/hsf-training-matplotlib/.vendor/bundle/ruby/3.0.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)

(A bunch of output)

from /Users/guillermofidalgo/.gem/ruby/3.0.0/gems/bundler-2.2.29/exe/bundle:37:in `<top (required)>'
    from /Users/guillermofidalgo/.gem/ruby/3.0.0/bin/bundle:23:in `load'
    from /Users/guillermofidalgo/.gem/ruby/3.0.0/bin/bundle:23:in `<main>'
/Users/guillermofidalgo/Documents/Websites/hsf-training-matplotlib/.vendor/bundle/ruby/3.0.0/gems/jekyll-theme-primer-0.6.0/_sass/primer-support/lib/variables/typography.scss:5: Invalid US-ASCII character "\\xE2" (Sass::SyntaxError)

(Some more lines)

/Users/guillermofidalgo/Documents/Websites/hsf-training-matplotlib/.vendor/bundle/ruby/3.0.0/gems/sass-3.7.4/lib/sass/util.rb:1088:in `encode': "\\xE2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII (Encoding::UndefinedConversionError)

(you get the idea)

I'm wondering if anyone has had this issue before and how I could go about solving this?\

I've tried reinstalling jekyll and ruby but does not seem to change anything.

I've reinstalled the gems and no luck. Any ideas?

maxim-belkin commented 2 years ago
Conversion error: Jekyll::Converters::Scss encountered an error while converting 'assets/css/style.scss':
                    Invalid US-ASCII character "\xE2" on line 5
jekyll 3.9.0 | Error:  Invalid US-ASCII character "\xE2" on line 5

I think Jekyll complains about style.scss file that you added to assets/css directory -- check its line 5 or delete it, if you don't need it.

maxim-belkin commented 2 years ago

\xe2 is most likely a "smart quotation mark" that should be replaced with '

GuillermoFidalgo commented 2 years ago

There is no style.scss here. I'm not sure if this means that it's looking somewhere else.

guillermofidalgo@Guillermos-MacBook-Pro hsf-training-matplotlib % ls -ahltr assets/css/
total 1296
-rw-r--r--  1 guillermofidalgo  staff    25K Oct 18 12:42 bootstrap-theme.css
-rw-r--r--  1 guillermofidalgo  staff    47K Oct 18 12:42 bootstrap-theme.css.map
-rw-r--r--  1 guillermofidalgo  staff   143K Oct 18 12:42 bootstrap.css
-rw-r--r--  1 guillermofidalgo  staff   382K Oct 18 12:42 bootstrap.css.map
-rw-r--r--  1 guillermofidalgo  staff    23K Oct 18 12:42 katex.min.css
-rw-r--r--  1 guillermofidalgo  staff    10K Oct 18 12:42 lesson.scss
drwxr-xr-x  9 guillermofidalgo  staff   288B Oct 18 12:42 ./
-rw-r--r--  1 guillermofidalgo  staff   4.3K Oct 18 12:42 syntax.css
drwxr-xr-x  7 guillermofidalgo  staff   224B Oct 18 12:42 ../
maxim-belkin commented 2 years ago

I cloned your lesson and was able to build/serve a website without an issue. A few things to try:

  1. make clean then make serve
  2. Do you have LC_ALL and/or LANG set? What does locale charmap return?
GuillermoFidalgo commented 2 years ago
  1. Resulted in same issue as before
  2. I get
    
    $ locale
    LANG=""
    LC_COLLATE="C"
    LC_CTYPE="C"
    LC_MESSAGES="C"
    LC_MONETARY="C"
    LC_NUMERIC="C"
    LC_TIME="C"
    LC_ALL=

$ locale charmap US-ASCII

maxim-belkin commented 2 years ago

Try setting LANG to something.UTF-8. For example, in my case I have en_US.UTF-8.

maxim-belkin commented 2 years ago

If changing LANG doesn't help, try setting LC_ALL (to en_US.UTF-8 or anything else.UTF-8) instead.

GuillermoFidalgo commented 2 years ago

Changing LANG worked 😄 Thank you so much! I think I know why this was not set or changed. Some time ago I was trying to install a package on a remote machine and it used to complain about ascii encoding. Following a few forum posts I ended up unchecking the setting on the Mac terminal under "Advanced" that says "Set locale enviroment variables on startup".

That fixed my issue back then but must have brought up this issue now. Thanks again!

maxim-belkin commented 2 years ago

Thanks for the report, @GuillermoFidalgo. I think this is something we might want to tackle in the Makefile. By the way, I would recommend using make serve and make site instead of invoking Bundler directly.

GuillermoFidalgo commented 2 years ago

Thanks for the tip. I did it both ways and same output arose. I just happened to paste it with bundler here