The Crystal Programming Language Forum

VSCode running Task problem


I try to start my first crystal project with VSCode running on a WindowsSubsystem for Linux (WSL2) with Ubuntu 20.04.

I created a simple taskfile like this: tasks.json

"version": "2.0.0",
"tasks": [
		"type": "crystal",
		"command": "run",
		"file": "src/",
		"problemMatcher": [],
		"label": "Crystal: run - src/main",
		"group": {
			"kind": "build",
			"isDefault": true

Problem A:

When I run this task [Terminal]>[Run Task…] the code works fine, but the comes the following task error in the output window:

The task provider for “crystal” tasks unexpectedly provided a task of type “shards”.

How can I solve this?

Problem B:

I also created a launch.json:

   "configurations": [
    "preLaunchTask": "Crystal: run - src/",
    "type": "lldb",
    "request": "launch",
    "name": "Launch",
    "program": "${workspaceFolder}/main",
    "args": [],
    "cwd": "${workspaceFolder}"

With a click on [Run]>[Run without debugging] there comes up this one:

“unable to find executable for ‘home/udach/projects/rftsim/main/main’”

And in fact, there is no file. I manually buildt the file and moved it to the expected loction and it works fine.

How can I modify the task (from Problem A) to build the file?

Whenever I add something like
“args”: ["-o main"]
or even
“args”: []

a new error comes up:

"There is no task provider registered for tasks of type “crystal”.

Any ideas?



Hi Bob,

I am not familiar with vscode & wsl, but I’ve used the following configurations to build and debug from vscode Debug Crystal in VSCode via CodeLLDB - DEV Community

1 Like

This is because some commands included with the plugin use shards and not crystal as a runner.
The message is a warning not related to the command you are using.

Actually the plugin has not debug capabilities.

Thank you for your help.

In my VS-Code there are now the following extensions enabled:

  • Remote-WSL (ms-vscode-remote.remote-wsl)
  • Crystal Language (crystal-lang-tools.crystal-lang)
  • Code Runner (formulahendry.code-runner)

For quick running the code (testing) I can use [Ctr] + [Alt] + [N] or Mouse-Rightclick > [Run Code]. This uses the Code Runner.

To build the code (for faster execution) I use the command-line.

I disabled any LLDB, launch and task stuff.

Maybe this will help other Newbies.