slint-ui/slint · error · Error

failed ( )

Error message

${cmd} ${args.join(" ")} failed (${e.code}):
${e.stdout}
${e.stderr}

What it means

The run() helper in packaging.mts wraps child process failures: when the spawned command exits non-zero or fails, it throws an Error embedding the command line, exit code, and captured stdout/stderr for diagnosis.

Solutions

  1. Read the embedded exit code, stdout and stderr in the message to find the underlying failure.
  2. Fix the root cause (login to the registry, install missing tool, correct arguments).
  3. Re-run the failing command manually to reproduce and debug interactively.
  4. Catch the error in calling scripts and surface it in CI logs.

Example fix

// before
await run('npm', ['publish']);
// after
try {
  await run('npm', ['publish']);
} catch (e) {
  console.error('publish failed:', e.message);
  process.exitCode = 1;
}
Defensive patterns

Strategy: try-catch

Validate before calling

for (const tool of ['npm', 'cargo']) {
  if (!run('which', [tool]).stdout.trim()) throw new Error(`${tool} not installed`);
}

Try / catch

try {
  await run('npm', ['publish']);
} catch (e) {
  console.error(e.message); // includes cmd, exit code, stdout, stderr
  process.exitCode = 1;
}

Prevention

When it happens

Trigger: npm/pack script invocations during packaging (build, publish, cargo commands) that exit non-zero or cannot spawn, e.g. a missing tool in PATH.

Common situations: Publishing npm packages without login, cargo/rustup missing in CI, network failures during npm publish, wrong directory passed to a build command.

Related errors


AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16). Data as JSON: /api/errors/c2f48697595a8f22. Report an issue: GitHub.

Appendix: source

Thrown at api/node/scripts/packaging.mts:70

export async function run(
    cmd: string,
    args: string[],
    opts: { cwd?: string; env?: NodeJS.ProcessEnv } = {},
): Promise<RunResult> {
    try {
        const { stdout, stderr } = await execFileAsync(cmd, args, {
            encoding: "utf8",
            maxBuffer: 64 * 1024 * 1024,
            // npm/npx/pnpm are .cmd shims on Windows, which execFile cannot launch
            // directly; run through the shell there. (The args below are package
            // names and ./-relative paths, so no extra quoting is needed.)
            shell: process.platform === "win32",
            ...opts,
        });
        return { stdout, stderr };
    } catch (error) {
        const e = error as { stdout?: string; stderr?: string; code?: number };
        throw new Error(
            `${cmd} ${args.join(" ")} failed (${e.code}):\n${e.stdout}\n${e.stderr}`,
        );
    }
}

function editManifest(
    file: string,
    edit: (manifest: Record<string, any>) => void,
): void {
    const manifest = JSON.parse(readFileSync(file, "utf8"));
    edit(manifest);
    writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\n`);
}

/** Pack a single platform's prebuilt native binary into an npm package tarball. */
export async function packBinary(opts: {
    config: string; // napi binaries config (binaries.json / binaries-dev.json)
    target: string; // napi-rs platform suffix, e.g. linux-x64-gnu

View on GitHub (pinned to bb937076de)