t.niese
t.niese

Reputation: 40842

Setting working directory in VSCode 14.6.x when using CMake Tools to something else then build directory

Since the update of CMake Tools 1.4.2 (Incorrect run folder #1395) the working directory of the launched binary isn't the workspace directory anymore, but the build directory (due to that files loaded with relative paths are not found anymore).

I tried to figure out in the release notes and the settings if there were some changes that cause that behavior, but I'm not able to find a reason or a solution for that.

The setup is:

I tried to set the cwd using launch.json, but I'm not able to get it to work.

My launch.json currently looks that way:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

Does anyone know how the working directory can be changed?

Upvotes: 2

Views: 5348

Answers (1)

t.niese
t.niese

Reputation: 40842

For debugging it can be changed with:

   "cmake.debugConfig": {
            "cwd": "${workspaceFolder}"
    },

For a regular run/launch it is currently not possible without changing the source of the extension.

Upvotes: 6

Related Questions