microsoft / microsoft/vscode-java-debug
"Command 'cmd' not found" when running Java code with WSL as the default profile
未關閉
還沒有人認領這個 Issue。
ai-triaged
bug
launch
terminal
- 主要語言
- TypeScript
- 星號
- 591
- 分支
- 429
- 平均合併
- 1 天 9 小時
- 30 天內合併 PR
- 19
描述
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
- Use Ubuntu (WSL) as the default shell
- Try to Run or Debug a Java project
- The runner/debugger fails with the above error
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
此故障顯示在 scripts/launcher.bat 中,並且會在以 Ubuntu 或 WSL 作為預設 shell 啟動 Run 或 Debug 時發生。在 Windows 10 上重現這些步驟,檢查 launcher 命令是如何形成的,並在 Bash 和 Fish 中驗證結果;當 Java 程式可以執行和除錯且不出現「Command 'cmd' not found」錯誤時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java, typescript, vscode
- 領域
- devtools, operating-systems
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100