vscode-java-debug icon indicating copy to clipboard operation
vscode-java-debug copied to clipboard

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

Open erazemk opened this issue 4 years ago • 3 comments
trafficstars

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

erazemk avatar Apr 12 '21 10:04 erazemk

The latest debugger 0.37.0 has removed launcher.bat from the command line, could you retry it again?

testforstephen avatar Dec 01 '21 07:12 testforstephen

The latest debugger 0.37.0 has removed launcher.bat from the command line, could you retry it again?

I don't use Windows anymore so I can't test this, sorry.

From my error report I can see the problem was that fish didn't recognise cmd as a valid command, so if the extension still runs cmd, the problem is most likely still present.

A possible fix was also described in the issue, changing cmd to cmd.exe, has that been tested?

erazemk avatar Dec 01 '21 11:12 erazemk

Anyone found a fix for this?

cieranholmes avatar Mar 11 '24 10:03 cieranholmes