diff --git a/src/main/utils/shell-env/compute-shell-environment.injectable.ts b/src/main/utils/shell-env/compute-shell-environment.injectable.ts index e3a60fcd03..8307f1f319 100644 --- a/src/main/utils/shell-env/compute-shell-environment.injectable.ts +++ b/src/main/utils/shell-env/compute-shell-environment.injectable.ts @@ -6,7 +6,7 @@ import type { AsyncResult } from "../../../common/utils/async-result"; import { getInjectable } from "@ogre-tools/injectable"; import isWindowsInjectable from "../../../common/vars/is-windows.injectable"; -import { disposer } from "../../../common/utils"; +import { disposer, hasTypedProperty, isString } from "../../../common/utils"; import computeUnixShellEnvironmentInjectable from "./compute-unix-shell-environment.injectable"; export type EnvironmentVariables = Partial>; @@ -47,6 +47,13 @@ const computeShellEnvironmentInjectable = getInjectable({ }; } + if (error && hasTypedProperty(error, "stderr", isString)) { + return { + callWasSuccessful: false, + error: `${error}:\n${error.stderr}`, + }; + } + return { callWasSuccessful: false, error: String(error), diff --git a/src/main/utils/shell-env/compute-unix-shell-environment.injectable.ts b/src/main/utils/shell-env/compute-unix-shell-environment.injectable.ts index 668fa95aea..097dbf9df6 100644 --- a/src/main/utils/shell-env/compute-unix-shell-environment.injectable.ts +++ b/src/main/utils/shell-env/compute-unix-shell-environment.injectable.ts @@ -64,15 +64,19 @@ const computeUnixShellEnvironmentInjectable = getInjectable({ env, }); const stdout: Buffer[] = []; + const stderr: Buffer[] = []; opts.signal?.addEventListener("abort", () => shellProcess.kill()); shellProcess.stdout.on("data", b => stdout.push(b)); + shellProcess.stderr.on("data", b => stderr.push(b)); shellProcess.on("error", (err) => reject(err)); shellProcess.on("close", (code, signal) => { if (code || signal) { - return reject(new Error(`Unexpected return code from spawned shell (code: ${code}, signal: ${signal})`)); + return reject(Object.assign(new Error(`Unexpected return code from spawned shellPath=${shellPath} (code: ${code}, signal: ${signal})`), { + stderr: Buffer.concat(stderr).toString("utf-8"), + })); } try {