(async ()=> {
const process= Deno.run( { cmd: [ 'invalid-command', ], }, );
console.log( await process.status(), );
})();
It should log { code: 127, success: false }. But in fact, an error thrown.
I have been taking a look at this issue, and this error at the surface is due to a method call to map from the cmd field of first parameter of the Deno.run.
cmd does not have a default value and crashes if undefined or not an array. There is also this assertion, assert(request.cmd.length > 0). Perhaps more friendly logging would be helpful here.
When args is replaced with cmd in the code above, this is the new error:
error: Uncaught NotFound: No such file or directory (os error 2)
at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
at Object.run ($deno$/ops/process.ts:41:10)
at Object.run ($deno$/process.ts:118:15)
at file:///Users/barronwei/Desktop/test.js:2:22
at file:///Users/barronwei/Desktop/test.js:5:3
If no one else is working on this, I would love to continue working on this issue!
@barronwei Thanks for the analysis and a patch would be very welcome!
Great issue @barronwei, hope you can fix it!
cmddoes not have a default value and crashes ifundefinedor not an array.
This issue is open before parameter name args breaking change to cmd. And I've forgot to update it. That's two different issues:
@Fenzland Appreciate the distinction. I will keep this in mind!
@Fenzland I believe exit code 127 is Bash specific. If the command dos not exist, Tokio does not successfully spawn a new process through Command::spawn, and results in an error. Anything to keep in mind when handling this, @ry?
~/src/deno> cat x.js
(async ()=> {
const process= Deno.run( { cmd: [ 'invalid-command', ], }, );
console.log( await process.status(), );
})();
~/src/deno> deno run --allow-run x.js
error: Uncaught NotFound: No such file or directory (os error 2)
at Object.jsonOpSync (core.js:247:13)
at opRun (deno:cli/rt/40_process.js:19:17)
at Object.run (deno:cli/rt/40_process.js:103:17)
at file:///Users/rld/src/deno/x.js:2:22
at file:///Users/rld/src/deno/x.js:5:3
This seems correct
Most helpful comment
I have been taking a look at this issue, and this error at the surface is due to a method call to
mapfrom thecmdfield of first parameter of theDeno.run.cmddoes not have a default value and crashes ifundefinedor not an array. There is also this assertion,assert(request.cmd.length > 0). Perhaps more friendly logging would be helpful here.When
argsis replaced withcmdin the code above, this is the new error:If no one else is working on this, I would love to continue working on this issue!