open-cli-tools / open-cli-tools/concurrently
Running concurrently on PowerShell seems to be running the commands on cmd
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.9k
- Forks
- 281
- Avg merge
- 17h 12m
- Merged PRs (30d)
- 1
Description
Problem:
When I am executing some command like this on PowerShell (also on PowerShell Core v7.1.0) on Windows 10:
concurrently --kill-others 'sleep 2' 'sleep 5'
I am getting response like this:
[0] 'sleep' is not recognized as an internal or external command,
[0] operable program or batch file.
[1] 'sleep' is not recognized as an internal or external command,
[1] operable program or batch file.
[0] sleep 2 exited with code 1
--> Sending SIGTERM to other processes..
[1] sleep 5 exited with code 1
Expected behavior:
It should be as shown in this GIF in README.
My Analysis:
sleep in PowerShell is an alias for Start-Sleep which is not available in cmd. I tried replacing sleep with its original name itself but that also didn't worked. Then I tried running concurrently 'ls' (another alias), it didn't worked. Tried with dir instead (the cmd equivalent) and it worked giving structure in cmd's style. (In PowerShell, dir is an alias for Get-ChildItem, which presents the output in quite a different way from cmd's dir). Clearly, whatever concurrently is running, it is running on cmd.
Also the error message, if it had been PowerShell, would be
The term 'ProgramName' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
But in case of cmd, it is like:
'ProgramName' is not recognized as an internal or external command,
operable program or batch file.
which again proves my point, that concurrently even after being invoked from PowerShell is running code on cmd.
What's the issue here?
I want to run my scripts on PowerShell if I am invoking it from PowerShell.
Some more analysis:
I have git for Windows installed in my system, so I tried running concurrently from git-bash (MinGW64), there concurrently is working fine. It is executing passed commands using the MinGW shell only.
Current Workaround:
Use PowerShell as if you are invoking it from cmd:
concurrently --kill-others "pwsh -Command 'sleep 2'" "pwsh -Command 'sleep 5'"
However, if I change double quotes with single quotes and vice-versa, I get this error:
~> concurrently --kill-others 'pwsh -Command "sleep 2"' 'pwsh -Command "sleep 5"'
C:\Users\brc-dd\AppData\Roaming\npm\node_modules\concurrently\src\command-parser\expand-npm-shortcut.js:3
const [, npmCmd, cmdName, args] = commandInfo.command.match(/^(npm|yarn|pnpm):(\S+)(.*)/) || [];
^
TypeError: commandInfo.command.match is not a function
at ExpandNpmShortcut.parse (C:\Users\brc-dd\AppData\Roaming\npm\node_modules\concurrently\src\command-parser\expand-npm-shortcut.js:3:63)
at C:\Users\brc-dd\AppData\Roaming\npm\node_modules\concurrently\src\concurrently.js:72:69
at arrayMap (C:\Users\brc-dd\AppData\Roaming\npm\node_modules\concurrently\node_modules\lodash\lodash.js:639:23)
at map (C:\Users\brc-dd\AppData\Roaming\npm\node_modules\concurrently\node_modules\lodash\lodash.js:9580:14)
at Function.flatMap (C:\Users\brc-dd\AppData\Roaming\npm\node_modules\concurrently\node_modules\lodash\lodash.js:9283:26)
at C:\Users\brc-dd\AppData\Roaming\npm\node_modules\concurrently\src\concurrently.js:72:33
at Array.reduce (<anonymous>)
at parseCommand (C:\Users\brc-dd\AppData\Roaming\npm\node_modules\concurrently\src\concurrently.js:71:20)
at C:\Users\brc-dd\AppData\Roaming\npm\node_modules\concurrently\src\concurrently.js:36:29
at arrayMap (C:\Users\brc-dd\AppData\Roaming\npm\node_modules\concurrently\node_modules\lodash\lodash.js:639:23)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the command-shell behavior from PowerShell on Windows, then inspect src/concurrently.js and src/command-parser/expand-npm-shortcut.js, which appear in the reported stack trace. Determine how command strings are spawned and parsed, including the quoted pwsh workaround; done means PowerShell-invoked commands use the expected shell without breaking command parsing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, powershell, typescript
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100