xmake-io / xmake-vscode

🍩 A XMake integration in Visual Studio Code
https://xmake.io
Apache License 2.0
232 stars 56 forks source link

can not using the xmake command in window vscode #194

Open kyrosle opened 1 year ago

kyrosle commented 1 year ago

Xmake Version

v2.7.8+HEAD.87dff1ef4

Operating System Version and Architecture

win11

Describe Bug

using the xmake command to creat project or run the project, this error will show:

Could not access file '/d': "The system cannot find the file specified. (os error 2)"

my vscode revlant setting:

  "terminal.integrated.profiles.windows": {
    "Nu": {
      "path": "C:\\Users\\xijhe\\.cargo\\bin\\nu.exe"
  },
  "terminal.integrated.profiles.linux": {
    "Nu": {
      "path": "/home/kyros/.cargo/bin/nu"
    }
  },
  "terminal.integrated.defaultProfile.windows": "Nu",
  "terminal.integrated.defaultProfile.linux": "Nu",
  "editor.accessibilitySupport": "off",
  "scm.countBadge": "focused",
  "terminal.external.linuxExec": "/home/kyros/.cargo/bin/nu",
  "terminal.external.windowsExec": "C:\\Users\\xijhe\\.cargo\\bin\\nu.exe",

i using nushell in vscode. the the running command would have something \d \c which casuse the error.

Expected Behavior

image

Project Configuration

No response

Additional Information and Error Logs

No response

GustafXTT commented 1 year ago

Same here, I tried Nu and MSYS 2 Fish Shell on Windows both got the same error

Error messages:

 *  正在执行任务: xmake -w 

error: Unable to read input file: Is a directory
warning: Error while reading file /d

 *  终端进程“C:\msys64\usr\bin\fish.exe /d /c xmake -w”已终止,退出代码: 127。 
 *  终端将被任务重用,按任意键关闭。
GustafXTT commented 1 year ago

BTW it will work properly in Powershell in my environment

lionyie commented 11 months ago

This bug seems to belong to vscode. I am also waiting for a fix. https://github.com/microsoft/vscode/issues/169821

Doekin commented 8 months ago

该问题与vscode的API--ShellExecution有关

当我们使用xmake的相关命令时,扩展会生成对应的command,然后尝试在shell中执行。参考terminal.ts

问题在于ShellExecution会尝试将command作为参数,传递给非交互模式的shell执行。对于 bash ,会在vscode集成终端中生成任务 bash -c "xmake command",对于cmd ,则是 cmd /d /c "xmake command" 在 bash / powershell / cmd 中,这可以正常工作。而这里使用的Nushell 比较小众,vscode没有相关配置,fallback到了cmd 的模板,即尝试执行 nu /d /c "xmake command",因而产生错误

要解决这一问题,可以使用ProcessExecution或者CustomExecution以代替ShellExecution。cmake-tools的实现方法 也许能提供一些参考