Unable to run the Jekyll in VS code

I’m trying to develop a static page, but so far I can’t get it to run locally. I have Ruby+Devkit 2.7.4-1 (x64) installed, with the M

I’ve done the quickstart tutorial from jekyllrb.com, and I’ve verified that I got bundler and jekyll installed.

C:\Users\Morten Arntun\.vscode\Bodo makerspace website_Cookie\Makerspace_bodo_cookie>jekyll -v
jekyll 4.2.1

C:\Users\Morten Arntun\.vscode\Bodo makerspace website_Cookie\Makerspace_bodo_cookie>bundle -v
Bundler version 2.2.31

C:\Users\Morten Arntun>gem -v
3.1.6

This is the output from the terminal in VScode when I try to run it.

PS C:\Users\Morten Arntun\.vscode\Bodo makerspace website_Cookie\Makerspace_bodo_cookie> bundle exec jekyll serve
bundle : The term 'bundle' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ bundle exec jekyll serve
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (bundle:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

The strange thing is, when I try to run it in CMD, it looks like its doing something, but it doesn’t complete.

PS C:\Users\Morten Arntun\.vscode\Bodo makerspace website_Cookie\Makerspace_bodo_cookie> bundle exec jekyll serve --livereload
Configuration file: C:/Users/Morten Arntun/.vscode/Bodo makerspace website_Cookie/Makerspace_bodo_cookie/_config.yml
                    ------------------------------------------------
      Jekyll 4.2.1   Please append `--trace` to the `serve` command
                     for any additional information or backtrace.
                    ------------------------------------------------
Traceback (most recent call last):
        29: from C:/Ruby27-x64/bin/jekyll:23:in `<main>'
        28: from C:/Ruby27-x64/bin/jekyll:23:in `load'
        27: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/exe/jekyll:15:in `<top (required)>'
        26: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
        25: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
        24: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
        23: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
        22: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
        21: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
        20: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
        19: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/command.rb:91:in `each'
        18: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
        17: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/commands/build.rb:30:in `process'
        16: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/commands/build.rb:30:in `new'
        15: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:36:in `initialize'
        14: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:133:in `setup'
        13: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:319:in `instantiate_subclasses'
        12: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:319:in `tap'
        11: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:321:in `block in instantiate_subclasses'
        10: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:321:in `map!'
         9: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:321:in `block (2 levels) in instantiate_subclasses'
         8: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:321:in `new'
         7: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `initialize'
         6: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `fetch'
         5: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `block in initialize'
         4: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `new'
         3: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:13:in `initialize'
         2: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `start_dev_server'
         1: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `open'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `initialize': No connection could be made because the target machine actively refused it. - connect(2) for "localhost" port 8124 (Errno::ECONNREFUSED)
        28: from C:/Ruby27-x64/bin/jekyll:23:in `<main>'
        27: from C:/Ruby27-x64/bin/jekyll:23:in `load'
        26: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/exe/jekyll:15:in `<top (required)>'
        25: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
        24: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
        23: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
        22: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
        21: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
        20: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
        19: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
        18: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/command.rb:91:in `each'
        17: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
        16: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/commands/build.rb:30:in `process'
        15: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/commands/build.rb:30:in `new'
        14: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:36:in `initialize'
        13: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:133:in `setup'
        12: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:319:in `instantiate_subclasses'
        11: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:319:in `tap'
        10: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:321:in `block in instantiate_subclasses'
         9: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:321:in `map!'
         8: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:321:in `block (2 levels) in instantiate_subclasses'
         7: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.1/lib/jekyll/site.rb:321:in `new'
         6: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `initialize'
         5: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `fetch'
         4: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `block in initialize'
         3: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `new'
         2: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:13:in `initialize'
         1: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:61:in `start_dev_server'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/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)

Any tips to what I’m doing wrong?

connect(2) for "localhost" port 8124 (Errno::ECONNREFUSED) that is a weird error, never seen that before.

ahh - I think that is for postcss - are you starting a site from scratch or did someone give you something as a starter?

I think postcss may need node and if you don’t have node installed then that error would make sense.

For vs code maybe you just need to restart it? if it was open while you installed jekyll then the path stuff may not be recognized until you re-open it.

1 Like

Thanks for the reply. I have tried to both close VS code and reboot my computer, but no luck.

You can try configure VS Code to use shell settings to pick up the PATH or bin directories.

I’ve had colleagues experience issues where their IDE (Storm or VS Code) had their IDE terminal not find commands but in a standalone terminal app it works fine.

I got it to work when i made a jekyll site from scratch.

I tried to delete some random things in the _config-file until I got the error fixed, now it tries to build it at least…

1 Like

I don’t like adding stuff to the plugins in config.

I prefer to add to Gemfile, because then I know the plugin is definitely installed and not just a name added in plugins that points to nothing.

And also because adding to plugins enables a plugin, which can be done elegantly in Gemfile e.g. demo

group :jekyll_plugins do
  gem "jekyll-sitemap", "~> 1.4"
end

When it comes to GitHub Pages (not Netlify), then plugins matters a lot because GH Pages ignores Gemfile.

I checked the gemfile, and it seems to be included there as well.

# frozen_string_literal: true

source "https://rubygems.org"
gem "jekyll", "~> 4.1"
gem "jekyll-feed", "~> 0.15.0"
gem "jekyll-postcss", '~> 0.4.0'
gem "jekyll-purgecss"
gem "jekyll-soopr-seo-tag"
gem "jekyll-minifier"
gem 'jekyll-sitemap'
gem "rouge"

gem "webrick", "~> 1.7"

I tried to remove the plugins in the config, but when I do the site looks like garbage. The same thing happens when I upload it to Github Pages, so it seems to me that there are some compatibility issues with the plugins both when I try to run them locally and when I try to run it in Github.

It seems to work fine when I host it on Netlify.com though.

did you install postcss on its own? I don’t use it but the jekyll-postcc docs say you need to install it on its own before using it with jekyll.

Where did you get the site you are working on that has all those gems?

Adding a gem to Gemfile is not enough

You need to actually enable it

gem "jekyll", "~> 4.1"

group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.15.0"
  gem "jekyll-postcss", '~> 0.4.0'
  gem "jekyll-purgecss"
  # ...
end

I would not bother with rouge in your Gemfile as it is already installed when installing Jekyll

https://rubygems.org/gems/jekyll/

GitHub Pages does not let you you install custom gems or use Jekyll 4. Only the limited set. As I said before, the Gemfile is ignored and you must enable to in config file. But your Jekyll 4 site with soopr plugin indicates GH Pages is not gonna work for you so stick with Netlify.

Back to you original question.

The issue is bundle cannot be found inside VS Code terminal, and presumably other custom installed tools can’t be found too. So this is not going to be directly related to Jekyll.

The VS Code settings and website documentation will help there.

Maybe there is a GH issue regarding windows and terminal. Could not find

Once Jekyll is running and if you cannot view the site or the css conversion fails, then open up a new forum post around postcss