Skip to content

fix: The DAP run configuration's working directory is now used when creating the server process if available (fixes #1684) - #1685

Merged
angelozerr merged 1 commit into
redhat-developer:mainfrom
SCWells72:issue1684
Oct 2, 2026

Conversation

@SCWells72

@SCWells72 SCWells72 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

The title pretty much says it all, but this addresses an issue where DAP server processes are executed without any explicit working directory, therefore requiring any path-based server command-line arguments to be fully-qualified and not allowing the server process to find working directory-relative context like local configuration files.

Here's evidence of it working:

Run configuration
image

Server process
image

… is used for the executed DAP server process.
@angelozerr

Copy link
Copy Markdown
Contributor

Hey @SCWells72 !

Your PR looks good, when it will be finished please switch to ready PR.


protected @NotNull GeneralCommandLine createStartServerCommandLine(@Nullable String command) throws ExecutionException {
return createStartServerCommandLine(command, Collections.emptyMap(), false);
return createStartServerCommandLine(null, command, Collections.emptyMap(), false);

@SCWells72 SCWells72 Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted this delegated signature, but note that this method is unused. I didn't want to delete it in case it was considered part of the historical interface, but if it's truly unused, I can delete it as part of this work.

}

protected @NotNull GeneralCommandLine createStartServerCommandLine(@Nullable String command,
protected @NotNull GeneralCommandLine createStartServerCommandLine(@Nullable String workingDirectory,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the optional working directory as the first argument here.

command = command.replace($_PORT, String.valueOf(port));
}
GeneralCommandLine commandLine = createCommandLine(command, userEnvironmentVariables, includeSystemEnvironmentVariables);
if (StringUtils.isNotBlank(workingDirectory)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if the working directory is set and corresponds to a physical directory in the file system, I set it as the server process' working directory.

@Nullable
protected GeneralCommandLine createStartServerCommandLine(@NotNull RunConfigurationOptions options) throws ExecutionException {
if (options instanceof DAPRunConfigurationOptions dapOptions) {
String workingDirectory = dapOptions.getWorkingDirectory();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two changes are just getting the working directory from the DAP options (which take it from the run configuration) and passing it to createStartServerCommandLine().

package com.redhat.devtools.lsp4ij.internal;


import org.jetbrains.annotations.Contract;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I used StringUtils.isNotBlank() above for consistency with what was being used in the same class/method, I noticed that the IDE's nullability analysis still showed the value that was successfully evaluated as not being blank as potentially being null. Obviously that's not possible, and it's doing so because these methods don't use the @Contract annotation to inform the IDE's nullability analysis about these methods' contracts around null inputs. I've updated them to do so properly which should provide much better nullability analysis when/where they're used. It wouldn't be a bad idea to update other common methods that can return null (or non-null) based specifically on the nullability of their inputs so that the IDE's nullability analysis can be much more informed about when a value is or is not potentially null based on prior calls in the code path.

@SCWells72
SCWells72 marked this pull request as ready for review October 2, 2026 17:10
@angelozerr angelozerr added the dap Debugging Adapter Protocol label Oct 2, 2026
@angelozerr angelozerr added this to the 0.21.1 milestone Oct 2, 2026
@angelozerr
angelozerr merged commit 28e6356 into redhat-developer:main Oct 2, 2026
7 checks passed
@angelozerr

Copy link
Copy Markdown
Contributor

Thanks @SCWells72 !

@SCWells72
SCWells72 deleted the issue1684 branch October 2, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dap Debugging Adapter Protocol

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants