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
{{ message }}
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.
classSudoSpawnErrorextendsError{publicerr: any;publicstdout?: string;publicstderr?: string;constructor(err: any,stdout?: string,stderr?: string){super(`Error occurred in spawn.\n`+` err: ${err}\n`+` stdout: ${stdout}\n`+` stderr: ${stderr}\n`);this.err=err;this.stdout=stdout;this.stderr=stderr;}}asyncfunctionsudoExec(commands: string[]){returnnewPromise<{stdout: string;stderr: string}>((resolve,reject)=>{sudo.exec(`sh ./my-script.sh`,some_options,// There's no @types/sudo-prompt typings yet, so these are best-effort.(err: any,stdout?: string,stderr?: string)=>{if(err===undefined&&stdout!==undefined&&stderr!==undefined&&stdout.includes("success!")){resolve({ stdout, stderr });}else{reject(newSudoSpawnError(err,stdout,stderr));}});});}
that tries to run a script that should eventually print "success!".
The issue is that the error handling is quite different between linux and macOS. If the script returns with a non-zero exit code, the linux version includes a useful (not undefined) stderr:
{ Error: Error occurred in spawn.
err: Error: User did not grant permission.
stdout:
stderr: umount: /home/darthvader/nu/skainswo: target is busy.
at sudo.exec (/home/darthvader/nu/skainswo/nuvemfs/packages/cli/src/util.ts:108:18)
at /opt/nu-links/cli-node_modules/node_modules/sudo-prompt/index.js:114:11
at ChildProcess.exithandler (child_process.js:282:5)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
err: Error: User did not grant permission.
at /opt/nu-links/cli-node_modules/node_modules/sudo-prompt/index.js:111:23
at ChildProcess.exithandler (child_process.js:282:5)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5),
stdout: '',
stderr: 'umount: /home/darthvader/nu/skainswo: target is busy.\n' }
but on macOS:
{ Error: Error occurred in spawn.
err: Error: Command failed: bash /var/folders/dk/6wr_v2z91hdfz1y2q405wf740000gn/T/tmp-53671eyCwS3TKWlXD.tmp
umount(/Users/skainswo/nu/skainswo): Resource busy -- try 'diskutil unmount'
stdout: undefined
stderr: undefined
at sudo.exec (/Users/skainswo/nu/skainswo/nuvemfs/packages/cli/src/util.ts:110:18)
at /opt/nu-links/cli-node_modules/node_modules/sudo-prompt/index.js:163:31
at ChildProcess.exithandler (child_process.js:288:7)
at ChildProcess.emit (events.js:197:13)
at maybeClose (internal/child_process.js:978:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
err:
{ Error: Command failed: bash /var/folders/dk/6wr_v2z91hdfz1y2q405wf740000gn/T/tmp-53671eyCwS3TKWlXD.tmp
umount(/Users/skainswo/nu/skainswo): Resource busy -- try 'diskutil unmount'
at /opt/nu-links/cli-node_modules/node_modules/sudo-prompt/index.js:306:27
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:54:3) code: 1 },
stdout: undefined,
stderr: undefined }
Why is stderr given as undefined? It seems like the API should be consistent across platforms.
The text was updated successfully, but these errors were encountered:
I have a bit of code:
that tries to run a script that should eventually print
"success!"
.The issue is that the error handling is quite different between linux and macOS. If the script returns with a non-zero exit code, the linux version includes a useful (not
undefined
)stderr
:but on macOS:
Why is
stderr
given asundefined
? It seems like the API should be consistent across platforms.The text was updated successfully, but these errors were encountered: