microsoft / microsoft/vscode-java-debug

"Command 'cmd' not found" when running Java code with WSL as the default profile

Open
#978 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-triaged bug launch terminal
Dominant language
TypeScript
Stars
591
Forks
429
Avg merge
1d 9h
Merged PRs (30d)
19

Description

When running/debugging Java programs using the extension(s), while having WSL as the default terminal profile, the program can't be run and exits with the following error:

Command 'cmd' not found, but there are 17 similar ones.

fish:        
 cmd /C "c:\Users\<Username>\.vscode\extensions\vscjava.vscode-java-debug-0.32.1\scripts\launcher.bat "C:\Program Files\AdoptOpenJDK\jdk-11.0.10.9-hotspot\bin\java.exe" -Dfile.encoding=UTF-8 -cp C:\Users\<Username>\AppData\Roaming\Code\User\workspaceStorage\f2ff3effae7386c130fa74d8c23d1e02\redhat.java\jdt_ws\Izzivi_163d1b63\bin Izziv5 "

The error occurs on multiple shells (both Bash and Fish tested), so this is not a Fish-specific issue.

Calling cmd.exe instead of cmd might fix the issue, since cmd.exe is available from WSL, while just cmd isn't.

Environment
  • Operating System: Windows 10
  • JDK version: 11 (AdoptOpenJDK)
  • Visual Studio Code version: 1.55.1
  • Java extension version: (Java Extension Pack?) v0.13.0
  • Java Debugger extension version: v0.32.1
Steps To Reproduce
  1. Use Ubuntu (WSL) as the default shell
  2. Try to Run or Debug a Java project
  3. The runner/debugger fails with the above error

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The failure shows scripts/launcher.bat and occurs when Run or Debug is launched with Ubuntu or WSL as the default shell. Reproduce those steps on Windows 10, inspect how the launcher command is formed, and verify the result in both Bash and Fish; done means Java programs run and debug without the “Command 'cmd' not found” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript, vscode
Domain
devtools, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.