Repository navigation
fix: a DAP configuration created from a file starts in the file's directory, and gets its environment - #2271
Merged
lagergren merged 4 commits intoNov 25, 2026
Conversation
…ectory, and gets its environment A DAP configuration created from a file got the project's directory as its working directory, from the template of the DAP run configuration type. So the directory environment of redhat-developer#1693 (mise, direnv) of a subdirectory didn't apply to a file in it, unless the user set the working directory by hand. The template no longer sets a working directory. Without one, the Debug Adapter starts in the directory of the configuration's file, and without a file in the project's directory, as before. It gets that directory's environment. A working directory set in the configuration wins, and an existing configuration keeps the one it stored. `${workspaceFolder}` is the working directory if one is set, and otherwise the project's directory, so a launch configuration keeps the value it had. The empty Working directory field shows "File's directory" or "Project directory" as a placeholder; nothing new is stored. Fixes redhat-developer#1885
…adapter in the directory of its file
The DAP user guide said that a configuration created from a file keeps the project's directory, so that a subdirectory's environment needs its working directory set by hand. It now says where a debug adapter without a working directory runs, what `${workspaceFolder}` is then, and that a configuration created by an earlier version keeps the working directory it stored. The developer guide's descriptor gets its `${workspaceFolder}` from `LaunchUtils.getWorkspaceFolder`, and the guides of the user-defined debug adapters no longer ask for the project's directory as working directory.
…ing directory The screenshots of the Configuration tab showed a working directory filled in, with personal Windows paths, and most of them had no Installer tab. A configuration now has no working directory unless one is set, and the empty field shows where the debug adapter runs. Retaken from the real run configuration editor, in New UI Dark at 2x, with each debug adapter created from its bundled template: the general image of the user guide, and the ones of codelldb, go-delve, julia, python-debugpy, swift-lldb and vscode-js-debug. The File is a path in the project, the Working directory is empty with its "File's directory" placeholder, and the launch or attach configuration is the template's. The red boxes mark what the guides point at: the File, or the Attach mode of python-debugpy.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2271 +/- ##
==========================================
+ Coverage 55.84% 57.11% +1.26%
==========================================
Files 848 848
Lines 36283 36315 +32
Branches 5686 7515 +1829
==========================================
+ Hits 20264 20741 +477
+ Misses 13101 12593 -508
- Partials 2918 2981 +63 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… the current Configuration tab The screenshot of the TypeScript launch showed a very old editor: tabs in another order, `Type:` instead of `Debug Mode:`, no `Use the configuration:` choice, a JSON without its `name`, and a working directory filled in with a personal Windows path. Retaken from the real run configuration editor, in New UI Dark at 2x, as the other Configuration tab screenshots: the VSCode JS Debug server with `Launch TypeScript file` selected and the JSON of its template, the File `/home/user/demo/src/test.ts` in a red box, as the guide asks to update it, and an empty Working directory with its "File's directory" placeholder.
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1885, with option 2 from the issue, plus a visible placeholder, as #2233 did for user-defined language servers.
What
A DAP configuration created from a file got the project's directory as its working directory, which the template of the DAP run configuration type stored. So for a file in a subdirectory with its own
mise.tomlor.envrc, asuseEnv/test.jswithuseEnv/mise.tomlin #1660, the directory environment of #1693 didn't apply: its debug adapter ran with the project's tools unless the user set the working directory by hand.Change
File, or in theFileitself when it is a folder, such as a Go package. Without a file, it runs in the project's directory, as before. It gets that directory's environment.${workspaceFolder}: the working directory if one is set, as before, and otherwise the project's directory, the one the template stored. So launch configurations keep the value they have today:"cwd": "${workspaceFolder}"still names the project's directory for a configuration created from a file.${workspaceFolder}. An existing configuration keeps the working directory it stored, and a configuration created from the file of an existing one still copies it.LaunchUtils.getWorkspaceFolder(workingDirectory, project)andLaunchUtils.getWorkingDirectory(workingDirectory, file, project). A descriptor that reads the working directory itself for${workspaceFolder}, asdocs/dap/DeveloperGuide.mdshowed, gets an empty one for a new configuration; the guide now usesgetWorkspaceFolder.docs/dap/UserGuide.md,docs/dap/DeveloperGuide.md, and the guides of vscode-js-debug, go-delve, swift-lldb and julia. The screenshots of the Configuration tab, of the user guide and of codelldb, go-delve, julia, python-debugpy, swift-lldb and vscode-js-debug, are retaken from the real editor in New UI Dark at 2x: an empty Working directory with its "File's directory" placeholder, a File in the project, and the Installer tab, instead of personal Windows paths. So is the TypeScript launch screenshot of vscode-js-debug (configuration_ts_tab.png), which still showed a very old editor.Template configurations
DAPConfigurationFactory.createTemplateConfigurationstored the project's directory, and every DAP configuration is cloned from that template: one created from a file, and one added by hand. It now stores none, so both get the empty field and its placeholder, with one rule for where the debug adapter runs. A configuration added by hand without a file still runs in the project's directory. A template that the user edited, and IntelliJ stored, keeps its working directory.Tests
New
DAPConfigurationWorkingDirectoryTest(6 tests, heavy project on disk). It creates configurations as the run configuration producer does, from the template and throughDebugAdapterManager.prepareConfiguration, with a user-defined debug adapter whose command runs fix: a user-defined language server without a working directory starts in the project's directory, and gets its environment #2233'sWorkingDirectoryRecorder, and an environment variable that a testCommandLineEnvCustomizersets from the working directory. The cases:${workspaceFolder}is the project's directory;The environment is checked on 2025.1 and later, the platforms that have directory environments.
New
DAPSettingsEditorWorkingDirectoryTest(4 tests): the placeholder with and without a file, as the File field changes, and a stored working directory, which is shown and kept.Changed
LaunchUtilsPlatformTest(+2 tests):${workspaceFolder}with and without a working directory; a project's directory which isn't on disk, and the default project.Red-green: without the fix, 6 of the 10 tests of the new classes fail on 2024.2: the debug adapter of a file in
subruns in the project's directory, so does the one of a folder to debug, the template stores the project's directory, and the placeholders are missing. The other 4 pass, as they check what doesn't change. With the fix, all pass.Platforms: the new and changed classes, with
dap.configurations.*,dap.descriptors.*,LaunchUtilsTest,DAPDebugProcessInstallerTabTestandDebugAdapterManagerAttachSettingsTest, pass headless on IC 2024.2, IC 2025.3 and IU 2026.3: 62 tests each, 0 failures, 0 skipped.Behaviour change
${workspaceFolder}is still the project's directory. A set working directory still wins, and existing configurations keep theirsA debug adapter command that relied on the project's directory as its working directory, for example through a relative path, now resolves against the file's directory in a new configuration. To run it elsewhere, set the working directory, or use
$PROJECT_DIR$in the command.