Executing task fails with nushell set as default shell
I have Nushell set as my default shell in VS Code on Windows. When I run a test, I see the following:
* Executing task: phpunit.bat --colors=always 'c:/Users/Charles/Dev/Exercism/php/hamming/HammingTest.php'
Error:
× The system cannot find the file specified. (os error 2)
* The terminal process "C:\Users\Charles\scoop\shims\nu.exe /d /c phpunit.bat --colors=always 'c:/Users/Charles/Dev/Exercism/php/hamming/HammingTest.php'" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
If I manually run the following command, it works:
cmd.exe /d /c phpunit.bat --colors=always 'c:/Users/Charles/Dev/Exercism/php/hamming/HammingTest.php'
The extension works fine if I have Command Prompt, PowerShell, or Git Bash set as my default. Would it be be possible to force use of cmd.exe or detect if nushell is default?
The following commands work:
Executes and keeps nu running:
C:\Users\Charles\scoop\shims\nu.exe --execute 'phpunit.bat --colors=always "c:/Users/Charles/Dev/Exercism/php/hamming/HammingTest.php"'
Executes and exits nu after finished running:
C:\Users\Charles\scoop\shims\nu.exe --commands 'phpunit.bat --colors=always "c:/Users/Charles/Dev/Exercism/php/hamming/HammingTest.php"'
Note, I don't need the full path to nu.exe in the because I have it on my PATH.
I managed to get it working by adding the following to my settings.json:
"terminal.integrated.automationProfile.windows": {
"path": "pwsh.exe",
"args": ["-NoProfile"]
},
Note that I could not use cmd.exe because it does not like single quotes. Example:
Single quoted (cannot open file):
C:\Users\Charles>cmd.exe /d /c phpunit.bat --colors=always 'c:/Users/Charles/Dev/Exercism/php/hamming/HammingTest.php'
PHPUnit 9.5.25 #StandWithUkraine
Cannot open file "'c:/Users/Charles/Dev/Exercism/php/hamming/HammingTest.php'".
Double quoted (works fine):
C:\Users\Charles>cmd.exe /d /c phpunit.bat --colors=always "c:/Users/Charles/Dev/Exercism/php/hamming/HammingTest.php"
PHPUnit 9.5.25 #StandWithUkraine
........ 8 / 8 (100%)
Time: 00:00.011, Memory: 10.00 MB
OK (8 tests, 9 assertions)
PowerShell, on the other hand, works with both single and double-quoted:
C:\Users\Charles>pwsh.exe -NoProfile -Command "phpunit.bat --colors=always 'c:/Users/Charles/Dev/Exercism/php/hamming/HammingTest.php'"
PHPUnit 9.5.25 #StandWithUkraine
........ 8 / 8 (100%)
Time: 00:00.012, Memory: 10.00 MB
OK (8 tests, 9 assertions)
C:\Users\Charles>pwsh.exe -NoProfile -Command "phpunit.bat --colors=always "c:/Users/Charles/Dev/Exercism/php/hamming/HammingTest.php""
PHPUnit 9.5.25 #StandWithUkraine
........ 8 / 8 (100%)
Time: 00:00.011, Memory: 10.00 MB
OK (8 tests, 9 assertions)
Hi, I'm not very active in this repo unfortunately but I could accept a PR. It seems like two problems.
- Make it work with nushell
- Fix quotes for cmd (use double). The quotes are there now to work with spaces in path
I think the problem has to do with how vscode handles nushell since I'm running tasks and it will pick up the shell by default. And in your case it says that it tried running it like The terminal process "C:\Users\Charles\scoop\shims\nu.exe /d /c however from what you wrote it seems nushell doesn't have a /d /c arg and needs C:\Users\Charles\scoop\shims\nu.exe --commands.
Judging from that I assume vscode thinks nushell is cmd basically. But great you got it working with pwsh.