Skip to content

On Windows, a relative command with / is looked up in the PATH instead of the working directory #1896

Closed

Description

@muescha

Since #1693, a command without a path is looked up in the PATH of the working directory's environment. On Windows, a relative command with /, such as bin/server.cmd, also counts as a command without a path, so it can start a file from a PATH directory instead of the one relative to the working directory.

How it happens

CommandUtils.resolveExecutable checks only File.separatorChar, which is \ on Windows:

static void resolveExecutable(@NotNull GeneralCommandLine commandLine) {
String executable = commandLine.getExePath();
if (executable.indexOf(File.separatorChar) != -1) {
// A path to the executable, which the platform doesn't look up either
return;

So findInWindowsPath looks up bin/server.cmd in each directory of the PATH, as new File(directory, "bin/server.cmd"). If one of them happens to have a bin\server.cmd, that one starts. An absolute path like C:/tools/node.exe goes the same way, but it isn't found in a PATH directory, so it stays as it is.

The platform's own lookup up to 2026.2 checks File.separatorChar only too, so this isn't new in the lookup itself. The 2026.3 platform checks both characters:

https://github.com/JetBrains/intellij-community/blob/idea/263.7307.44/platform/platform-util-io/src/com/intellij/execution/configurations/GeneralCommandLine.java#L568

Possible direction

Treat a command with / or \ as a path, as the 2026.3 platform does, and leave it to the platform.

Claude Code found this by analyzing the code; it hasn't been reproduced by running it.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions