Skip to content

Relative workingDirectory in launch.json resolves against extension host cwd, not workspace #112

Description

Problem

In the debugger's createDebugAdapterDescriptor, when config.workingDirectory is set to a relative path (e.g. "./subdir"), it is used as-is for spawn's cwd without resolving against folder.uri.fsPath. This means relative workingDirectory values resolve against the extension host process's cwd rather than the workspace folder.

On Windows, drive-relative forms like C:foo are especially problematic.

Current code

let cwd = folder.uri.fsPath;
if (config.workingDirectory) {
    cwd = config.workingDirectory;
}

Suggested fix

Resolve relative workingDirectory against the workspace folder:

let cwd = folder.uri.fsPath;
if (config.workingDirectory) {
    cwd = path.isAbsolute(config.workingDirectory)
        ? config.workingDirectory
        : path.resolve(folder.uri.fsPath, config.workingDirectory);
}

Additional context

Surfaced during PR review of the fix for #33. This is pre-existing behavior, not a regression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdebugger

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions