VScode debug mode shows "Could not find the specified task"
Asked Answered
C

1

10

When trying to start a Debug session in vscode, it throws an error about not finding a specified task. I've already tried the solutions of other SO questions like this but without success.

launch.json:

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
      ...
    },
    {
        "name": "MSEventHubs_Audit",
        "type": "python",
        "request": "launch",
        "program": "${workspaceFolder}/audit-events.py",
        "console": "integratedTerminal",
        "args": [
            "config/config.ini",
        ],
        "envFile": "${workspaceFolder}/.env",
        "env": {"PYTHONPATH": "${workspaceRoot}"},
        "justMyCode": false,
        "preLaunchTask": {
            "task": "audit_tunnel"
        }
    },
    {
     ...
    },
]
}

tasks.json:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"command": "",
"args": [],
"tasks": [
    {
        "label": "activate_key",
        "type": "shell",
        "command": "smartOS_card_pin.sh",
        "args": [
            "${inputs:cardos_pass}"
        ],
        "group": "build",
    },
    {
        "label": "audit_tunnel",
        "type": "shell",
        "group": "build",
        "command": "ssh",
        "args": [
            "-NL",
            "port1:127.0.0.1:port2",
            "my_host"
        ],
        "dependsOn": "activate_key"
    },
    {
      ...
    }
],
"inputs": [
    {
    "id": "cardos_pass",
    "type": "promptString",
    "password": true
    }
]
}

I've been looking at it for a while and cannot figure out what I'm doing wrong. The proof my task is known by vscode is when the pop-up message appears

enter image description here

I click 'Configure Task', the 'audit_tunnel' appears as an option to edit.

enter image description here

What am I missing?

Connatural answered 11/5, 2020 at 9:34 Comment(2)
I would remove "command": "", "args": [], from the top of your tasks.json - that looks like the previous syntax. See code.visualstudio.com/Docs/editor/tasks#_migrating-to-tasks-200. Secondly, if you just run audit_tunnel by itself, can it be found? You could just put an echo in there to make it easy.Observer
Yes @Observer , I can run the task directly. And your suggestion did not work.Connatural
D
22

Change:

"preLaunchTask": {
            "task": "audit_tunnel"
        }

To:

"preLaunchTask": "audit_tunnel"
Dim answered 23/7, 2020 at 21:24 Comment(1)
The above at least improved things for me, now it's a bit more specific and says, "Could not find the task '/home/user/some/task.json'" even though the file exists.Podesta

© 2022 - 2024 — McMap. All rights reserved.