Debug Jekyll with VSCode

13 Jul 2023 in TIL

I needed to debug some custom Jekyll plugins using VSCode. Here’s how I did it:

  1. Install https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg
  2. Install the debug gem globally with gem install debug
  3. Create a .vscode/launch.json file in the project with the following contents (you may need ):
js
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "rdbg",
"name": "Debug Jekyll",
"request": "launch",
"script": "bin/jekyll build --config _config.yml --profile",
"args": [],
"askParameters": false,
}
]
}
  1. Ensure that bin/jekyll exists by running bundle binstubs jekyll
  2. Create a breakpoint then run by pressing F5 or running Start Debugging from the command palette.

You should now be able to inspect the running process using the debug tools available in VSCode.