mhanberg / jekyll-postcss

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

Could not connect to the PostCSS server (RuntimeError) #29

Open olakara opened 3 years ago

olakara commented 3 years ago

I am running jekyll with jekyll-process through docker compose:

version: '3.3'

services:
  jekyll:
    image: jekyll/jekyll:latest
    #    command: jekyll serve --watch --force_polling --verbose --trace
    command: jekyll serve --livereload --drafts --future --port 4000 --livereload_port 35729
    ports:
      - 4000:4000
    volumes:
      - .:/srv/jekyll
    environment:
      - JEKYLL_ROOTLESS=true

I keep getting error:

jekyll_1  | Configuration file: /srv/jekyll/_config.yml
jekyll_1  | jekyll 3.8.7 | Error:  Could not connect to the PostCSS server
jekyll_1  | /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:70:in `rescue in start_dev_server': Could not connect to the PostCSS server (RuntimeError)
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:61:in `start_dev_server'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:13:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `block in initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `fetch'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:295:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:295:in `block in instantiate_subclasses'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:294:in `map'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:294:in `instantiate_subclasses'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:116:in `setup'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:32:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:30:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:30:in `process'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `block in start'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `each'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `start'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/exe/jekyll:15:in `<top (required)>'
jekyll_1  |     from /usr/local/bundle/bin/jekyll:29:in `load'
jekyll_1  |     from /usr/local/bundle/bin/jekyll:29:in `<main>'
jekyll_1  | /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `initialize': Address not available - connect(2) for "localhost" port 8124 (Errno::EADDRNOTAVAIL)
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `open'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `start_dev_server'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:13:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `block in initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `fetch'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:295:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:295:in `block in instantiate_subclasses'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:294:in `map'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:294:in `instantiate_subclasses'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:116:in `setup'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:32:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:30:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:30:in `process'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `block in start'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `each'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `start'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/exe/jekyll:15:in `<top (required)>'
jekyll_1  |     from /usr/local/bundle/bin/jekyll:29:in `load'
jekyll_1  |     from /usr/local/bundle/bin/jekyll:29:in `<main>'

Any idea how to resolve this?

mhanberg commented 3 years ago

You need node js to use post css. I assume that the Jekyll image does not include it.

olakara commented 3 years ago

@mhanberg thanks for your input.. I did following: docker-compose run jekyll /bin/bash and ran node --version Looks like I have nodejs ..

image

Atem18 commented 3 years ago

@olakara Please remove the env var JEKYLL_ROOTLESS and try again.

rwgrier commented 3 years ago

I am seeing this same error when I attempt to deploy via Netlify. I feel like I'm doing something silly with my config.

Netlify Support Post: https://answers.netlify.com/t/deploy-failing-jekyll-tailwind-css/41017

Github Branch with all of my attempts: https://github.com/rwgrier/rwgrier.github.io/tree/tailwindcss

Atem18 commented 3 years ago

@rwgrier there is a 404 on your link

rwgrier commented 3 years ago

@Atem18 Sorry, I got kinda frustrated and gave up on it. I moved to a generated version of the Tailwind CSS file.

Atem18 commented 3 years ago

@rwgrier No problem, if you ever want to see a working example, please see my website here : https://github.com/Atem18/atemlire

olakara commented 3 years ago

@Atem18 I cloned your repo https://github.com/Atem18/atemlire.git and tried to run .. and ended up with the same error: image

all I did was run this command: docker run --name=atemlire-dev --volume="C:/Users/Lenovo/source/atemlire/app:/srv/jekyll" -p 4000:4000 -it jekyll/jekyll:4.2.0 jekyll serve --drafts --incremental

Atem18 commented 3 years ago

@olakara If you go upper, you will see the real error. It's probably because the node_modules are missing.

I pushed an update to my repo and the trick is to build your own image and override the ENTRYPOINT because for whatever reason, there is nodejs in the official Jekyll docker image but while it does install the Ruby Gems, it does not install the Node packages.

Do note that I did many tests with Docker Compose and there is always that error and I have no clue why it's not working with Docker Compose but it's working with Docker.

tyHdev commented 2 years ago

I am observing the same behavior with a very similar docker-compose.yml file for my Jekyll project. I tried building a custom image based on Ruby:3.0.2 with nodejs and npm installed explicitly, and with port 8124 exposed (not sure whether this is needed) and when attempting to run a container based on that image with docker-compose, am observing the same behavior as well.

guschiavon commented 2 years ago

I get the same error running with the following docker-compose.yml file:

services:
  jekyll:
    image: jekyll/jekyll:latest
    command: jekyll s -l
    ports:
      - 4000:4000
    volumes:
      - .:/srv/jekyll
codejanovic commented 2 years ago

@olakara @guschiavon
I could fix it by specifing the jekyll environment variable:

environment:
      - JEKYLL_ENV=development jekyll build