You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deno.run() is unable to execute .cmd files unless they include the .cmd extension.
Expected:
When running on Windows, "foo" should be able to execute command foo whether it has an .exe or .cmd extension. (And possibly others? Do people still use .bat?)
Reproduction:
// bug.tsasyncfunctionrun(...cmd: string[]){constp=Deno.run({cmd})awaitp.status()}// is an .exe:awaitrun("protoc","--version")// workaround works, but requires always checking for Windows.awaitrun("npm.cmd","--version")// Does not work:awaitrun("npm","--version")
Output:
deno run -A bug.ts
libprotoc 3.20.2
7.19.0
error: Uncaught (in promise) NotFound: program not found
const p = Deno.run({cmd})
^
at opRun (deno:runtime/js/40_process.js:33:16)
at Object.run (deno:runtime/js/40_process.js:116:17)
at run (file:///C:/Users/Cody/code/feoblog-client/private/protobuf/bug.ts:3:20)
at file:///C:/Users/Cody/code/feoblog-client/private/protobuf/bug.ts:9:7
Note:in both the Windows Command Prompt and PowerShell, both protoc and npm are runnable as commands without specifying a file extension:
You can check whether you're on windows and add a .cmd. However, this also requires you to know whether a particular tool is distributed on Windows as an .exe or a .cmd. (i.e.: a blanket: "if windows, add .cmd" isn't a suitable fix, since it breaks anything that's distributed as an .exe.)
The text was updated successfully, but these errors were encountered:
I was also confused about this a few months ago about this behavior in Rust's Command and investigated it then. This is expected behaviour. The same thing happens in node and is because CreateProcess in winapi does not check PATHEXT:
By the way, https://github.com/dsherret/deno_which will search the PATH using the PATHEXT on Windows to find the executable path. It might be useful for you. The annoyance is it requires permissions to read all the directories specified on the PATH in order to find the executable.
Another alternative is to run the command through cmd.
Problem:
Deno.run()
is unable to execute .cmd files unless they include the.cmd
extension.Expected:
When running on Windows, "foo" should be able to execute command
foo
whether it has an.exe
or.cmd
extension. (And possibly others? Do people still use.bat
?)Reproduction:
Output:
Note:in both the Windows Command Prompt and PowerShell, both
protoc
andnpm
are runnable as commands without specifying a file extension:Workaround
You can check whether you're on windows and add a
.cmd
. However, this also requires you to know whether a particular tool is distributed on Windows as an.exe
or a.cmd
. (i.e.: a blanket: "if windows, add .cmd" isn't a suitable fix, since it breaks anything that's distributed as an.exe
.)The text was updated successfully, but these errors were encountered: