Skip to content

DAP: a configuration created from a file keeps the project's directory as working directory, so a subdirectory's environment doesn't apply #1885

Done

Description

@lagergren

With directory environments (#1660, #1693), the working directory selects the environment that a debug adapter's process gets, such as the tools of a mise.toml or an .envrc. A DAP configuration created from a file keeps the project's directory as its working directory, so a file in a subdirectory with an environment of its own, as useEnv/test.js with useEnv/mise.toml in #1660, runs with the project's tools unless the user sets the working directory to the subdirectory.

How it happens

  • DAPConfigurationFactory.createTemplateConfiguration sets the working directory of the template to the project's directory.
  • DebugAdapterDescriptorFactory.prepareConfiguration, which a configuration created from a file goes through, sets the file but not the working directory.

Why it isn't a one-line change

The working directory is also the launch configuration's ${workspaceFolder} (LaunchUtils.getDapParameters passes it to the LaunchContext). Defaulting it to the file's directory would change what ${workspaceFolder} resolves to, for instance for paths that launch configurations give relative to it.

Possible direction

Default the working directory of a configuration created from a file to the file's directory, while ${workspaceFolder} stays the project's directory, for instance by resolving it from the project rather than from the working directory. Until then, #1693 documents that the working directory selects the environment.

Activity

  1. lagergren commented on Nov 7, 2026

    @lagergren
    CollaboratorAuthor

    @angelozerr before I put up a PR for this, which behavior do you want for a DAP configuration created from a file?

    1. Keep the project's directory as its working directory, as today. feat: support directory environment variables #1693 documents that the working directory selects the environment, so a file in a subdirectory with its own mise.toml needs its working directory set by hand.
    2. Default the working directory to the file's directory, and resolve ${workspaceFolder} from the project instead of from the working directory. A file then gets its own directory's environment, and launch configurations keep the same ${workspaceFolder} as today.
    3. Default the working directory to the file's directory, and keep ${workspaceFolder} as the working directory. This is simpler, but it changes what ${workspaceFolder} resolves to for every configuration created from a file in a subdirectory, for instance for paths that launch configurations give relative to it.

    I'd go with 2. It only changes configurations created after the change; existing ones keep their working directory.

  2. added
    bug
    dap
    on Nov 21, 2026
  3. lagergren commented on Nov 23, 2026

    @lagergren
    CollaboratorAuthor

    @angelozerr Coming back to my question above, before I put up a PR: which behaviour do you want for a DAP configuration created from a file? In short:

    1. Keep the project's directory as its working directory, as today. A file in a subdirectory with its own mise.toml or .envrc then needs its working directory set by hand.
    2. Default the working directory to the file's directory, and resolve ${workspaceFolder} from the project. The file gets its own directory's environment, and launch configurations keep the same ${workspaceFolder} as today.
    3. Default the working directory to the file's directory, and keep ${workspaceFolder} as the working directory. This is simpler, but it changes ${workspaceFolder} for every configuration created from a file in a subdirectory.

    I'd go with 2. Only configurations created after the change are affected; existing ones keep their working directory.

  4. added a commit that references this issue on Nov 26, 2026
    3558129
  5. added this to the 0.30.2 milestone on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdap

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions