Debugging Crystal with VS code

Hello,
I am trying to debug a crystal app using VS code. I followed what is explained here:
https://docs.amberframework.org/amber/examples/crystal-debug
but so far it does not work for me. The pre-launch task is trying to compile a file but I have an error saying target was not found in shard.yml. However shard.yml has this same file for its target ‘main’:

shard.yml:

targets:
isekai:
main: src/isekai.cr

tasks.json:

“label”: “Compile”,
“command”: “shards build --debug src/isekai.cr”,
“type”: “shell”

Somebody knows what I am doing wrong?

iirc you have to use the name you gave to the target, not the file (it’s already mentionned in shards.yml.
So for you it’d be: shards build --debug isekai

Thank you, that made it!

Hi @Guillaume I just saw this post, Currently I’m working on a new guide to debug crystal apps using VSCode, 'cause current guide has some outdated things :sweat_smile:

BTW, Thank @bew for the comment above, yeah --debug flag is pretty much obligatory here :+1:

3 Likes

Hi @faustinoaq,
First, I would like to appreciate your effort.
I ask about the new guide, is it available?
Best Regards

1 Like