Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running concurrently on PowerShell seems to be running the commands on cmd #254

Open
brc-dd opened this issue Jan 3, 2021 · 3 comments
Open

Comments

@brc-dd
Copy link

brc-dd commented Jan 3, 2021

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)
@panther7
Copy link

panther7 commented Mar 31, 2021

Same problem with quotes, you must call with backslash, like

concurrently \"command 1\" \"command 2\"

@balovbohdan
Copy link

Faced the same issue.
Screenshot 2021-06-02 at 13 00 23

@arneheycircle
Copy link

Unlike @brc-dd I am currently running into the exact same issue with MinGW64 (through git-bash). This is proving a major problem as running a command through concurrently starts cmd. This results in concurrently not shutting down cleanly as cmd waits for confirmation in the form of user input when 'Ctrl+C'ing something out of existence. ("Terminate batch job? (Y/N)"). It also makes me question the consistency for concurrently for projects with multiple developers on multiple environments. I would expect the commands to run in the shell they were executed from in the first place.

In the meantime, I will emulate the above fix and explicitly call a shell to execute my commands in, but it does feel like a very contrived way to parallelise execution and definitely doesn't work cross-platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants