mhanberg / jekyll-postcss

A plugin to use PostCSS plugins like Autoprefixer or Tailwind CSS with Jekyll.
MIT License
66 stars 12 forks source link

PostCSS: Exec Format Error (ENOEXEC) #27

Open sunilk4u opened 3 years ago

sunilk4u commented 3 years ago

I am trying to use tailwind in my Jekyll project but the postcss plugin throws a conversion error. Below are the logs while running Jekyll serve:

Conversion error: Jekyll::Converters::PostCss encountered an error while converting 'assets/css/main.scss':
                    Exec format error - C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-postcss-0.4.0/bin/postcss '{"raw_content":"@import \"tailwindcss/base\";\n@import \"tailwindcss/components\";\n@import \"tailwindcss/utilities\";\n\n\n"}'
Traceback (most recent call last):
        29: from C:/Ruby25-x64/bin/jekyll:23:in `<main>'
        28: from C:/Ruby25-x64/bin/jekyll:23:in `load'
        27: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/exe/jekyll:15:in `<top (required)>'
        26: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
        25: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
        24: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
        23: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
        22: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
        21: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
        20: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
        19: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `each'
        18: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
        17: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/commands/build.rb:36:in `process'
        16: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/commands/build.rb:65:in `build'
        15: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:28:in `process_site'
        14: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:80:in `process'
        13: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:211:in `render'
        12: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:538:in `render_pages'
        11: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:538:in `each'
        10: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:539:in `block in render_pages'
         9: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:547:in `render_regenerated'
         8: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:63:in `run'
         7: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:84:in `render_document'
         6: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:104:in `convert'
         5: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:104:in `reduce'
         4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:104:in `each'
         3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:106:in `block in convert'
         2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-postcss-0.4.0/lib/jekyll/converters/postcss.rb:39:in `convert'
         1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-postcss-0.4.0/lib/jekyll-postcss/socket.rb:20:in `write'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-postcss-0.4.0/lib/jekyll-postcss/socket.rb:20:in ``': Exec format error - C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/jekyll-postcss-0.4.0/bin/postcss '{"raw_content":"@import \"tailwindcss/base\";\n@import \"tailwindcss/components\";\n@import \"tailwindcss/utilities\";\n\n\n"}' (Errno::ENOEXEC)

Even with the only front matter in the scss file, it throws the same error.

main.scss file

---
---
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
kkgthb commented 3 years ago

Ditto. I have a teeny-tiny Jekyll theme _(just a _config.yml, a Gemfile, a Gemfile.lock, an index.html)_ that works fine when I run NODE_ENV=production JEKYLL_ENV=production bundle exec jekyll build or NODE_ENV=development JEKYLL_ENV=development bundle exec jekyll serve.

I'm walking through adding Tailwind to it using Steven Westmoreland's instructions at https://stevenwestmoreland.com/2021/01/using-tailwind-css-with-jekyll.html and when I run NODE_ENV=production JEKYLL_ENV=production bundle exec jekyll build after following all of his steps, I get the following error dump:

Configuration file: C:/example/_config.yml
            Source: C:/example
       Destination: C:/example/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
  Conversion error: Jekyll::Converters::PostCss encountered an error while converting 'assets/css/main.css':
                    Exec format error - C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/bin/postcss '{"raw_content":"@import \"tailwindcss/base\";\n@import \"tailwindcss/components\";\n@import \"tailwindcss/utilities\";"}'
                    ------------------------------------------------
      Jekyll 4.2.0   Please append `--trace` to the `build` command
                     for any additional information or backtrace.
                    ------------------------------------------------
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:20:in ``': Exec format error - C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/bin/postcss '{"raw_content":"@import \\"tailwindcss/base\\";\\n@import \\"tailwindcss/components\\";\\n@import \\"tailwindcss/utilities\\";"}' (Errno::ENOEXEC)
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:20:in `write'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:39:in `convert'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:106:in `block in convert'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:104:in `each'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:104:in `reduce'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:104:in `convert'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:84:in `render_document'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:63:in `run'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:547:in `render_regenerated'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:539:in `block in render_pages'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:538:in `each'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:538:in `render_pages'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:211:in `render'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:80:in `process'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:28:in `process_site'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/commands/build.rb:65:in `build'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/commands/build.rb:36:in `process'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `each'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
        from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/exe/jekyll:15:in `<top (required)>'
        from C:/Ruby27-x64/bin/jekyll:23:in `load'
        from C:/Ruby27-x64/bin/jekyll:23:in `<main>'

Any chance there's a bug in jekyll-postcss parsing CSS files w/ "Tailwind" imports on Windows?

sunilk4u commented 3 years ago

Well, I researched a bit and there is a high likelihood that the postcss gem plugin has a bug. Instead of using the gem postcss plugin , you can use postcss module for node.js and then set the output folder of generated CSS files to Jekyll's static folder.

There is a tailwind jekyll starter from which you can take hints from. -> Jekyll Tailwind Starter