1

Summary

  • Goal: to debug a C++ program I am working on.
  • Expected Results: After configuration, debugger runs to breakpoint and shows current state of variables, etc.
  • Actual Results: When trying to run the debugger on C++ code in VS Code, I get the error in the title. The pop up happens during the pre-launch build task:

The interruption occurs here:

 *  Executing task: cd C:\Users\wesle\source\repos\raycast/build && cmake --build . --config Debug 

Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  cuda_test.vcxproj -> C:\Users\wesle\source\repos\raycast\build\Debug\cuda_test.exe

Code:

I am using the auto-generated debug configuration for the Windows (launch) option, with the only addition being a preLaunchTask:

{
    // 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": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/Debug/cuda_test.exe",
            "args": [],
            "preLaunchTask": "build",
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "console": "externalTerminal"
        }
    ]
}

and this simple tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "cd ${workspaceFolder}/build && cmake --build . --config Debug"
        }
    ]
}

Question:

How do I fix this?

Things I tried:

  1. I think it might be because, somewhere, a path to "C:/Program Files/..." is being called without the surrounding quotes, and the space is an issue. However, I have searched for a reference to the Program Files directory in all of the following. Nowhere does a reference exist in these files:

    • settings.json
    • launch.json
    • c_cpp_properties.json
    • tasks.json
  2. Another thing I tried was to delete the tasks.json file completely and pre-build with debug configuration from the command line. I thought maybe cmake was being replaced with its full, unquoted path via the path env variable. The error persisted (actually popped up a little faster).

  3. I have uninstalled all plugins, except the C++ Tools and CMake Tools extensions.

  4. I have uninstalled and reinstalled the C++ and CMake extensions.

  5. I am most definitely running an instance of VS Code started from the developer console.

Notes

  1. The error is not present in the text output console. It is a system pop-up box. I don't know if this might be a clue:

enter image description here

  1. The build command in the pre-launch task works fine from the command line.
8
  • 8
    If a path has spaces or other nasty characters, enclose the path in double quotes. For example: "C:\Program Files\x86". Commented Jun 5, 2023 at 23:56
  • @ThomasMatthews As I mentioned under the section "Things I have tried", this has already been done, as there are no instances with nasty characters or spaces. Commented Jun 5, 2023 at 23:57
  • 3
    @rocksNwaves: 1) I completely agree. There are many reasons to choose VSCode over MSVS. Including "My boss told me to". 2) Clearly, at least ONE of your environment variables (or a CMake variable) expands to a path with a space (e.g. "C:\Program Files" or "C:\Program Files (x86)". SUGGESTION: Enable CMake "verbose mode", e.g. --trace, --trace-expand, and --trace-source=some_cmake_source Commented Jun 6, 2023 at 0:11
  • 2
    Assuming you've looked at everything in VSCode ... look at the files in "build*, and try enabling "trace" info in CMake. Commented Jun 6, 2023 at 0:17
  • 2
    These are among the most annoying of problems to remotely debug. Most of the time they only way to figure out what information needs to be in the question to make it answerable is to have already answered your own question. Is there any way you can break down the stages so you can at least narrow down which of them's trying to eat the suspected bad path? You can build properly, can you not? If you can, you can also discard CMake and friends from the problem set. Where is the debugger itself installed? Commented Jun 6, 2023 at 0:40

1 Answer 1

2

This problem drives me crazy too. After changing "console": "externalTerminal" to "console": "internalConsole", the problem is partially solved (except that everything is shown in vscode's DEBUG CONSOLE).

I don't know why externalTerminal is not OK, nowhere mentions it in the documentation.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.