{"record":{"id":"27e5d4c6740c1680","repo":"linera-io/linera-protocol","slug":"got-non-zero-error-code","errorCode":null,"errorMessage":"{}: got non-zero error code {}","messagePattern":"(.+?): got non-zero error code (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-base/src/command.rs","lineNumber":164,"sourceCode":"    fn spawn_into(&mut self) -> anyhow::Result<tokio::process::Child> {\n        self.kill_on_drop(true);\n        debug!(\"Spawning {:?}\", self);\n        let child = tokio::process::Command::spawn(self).with_context(|| self.description())?;\n        Ok(child)\n    }\n\n    async fn spawn_and_wait_for_stdout(&mut self) -> anyhow::Result<String> {\n        debug!(\"Spawning and waiting for {:?}\", self);\n        self.stdout(Stdio::piped());\n        self.stderr(Stdio::inherit());\n        self.kill_on_drop(true);\n\n        let child = self.spawn().with_context(|| self.description())?;\n        let output = child\n            .wait_with_output()\n            .await\n            .with_context(|| self.description())?;\n        ensure!(\n            output.status.success(),\n            \"{}: got non-zero error code {}\",\n            self.description(),\n            output.status,\n        );\n        String::from_utf8(output.stdout).with_context(|| self.description())\n    }\n\n    async fn spawn_and_wait(&mut self) -> anyhow::Result<()> {\n        debug!(\"Spawning and waiting for {:?}\", self);\n        self.kill_on_drop(true);\n\n        let mut child = self.spawn().with_context(|| self.description())?;\n        let status = child.wait().await.with_context(|| self.description())?;\n        ensure!(\n            status.success(),\n            \"{}: got non-zero error code {}\",\n            self.description(),","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-base/src/command.rs#L146-L182","documentation":"CommandExt::spawn_and_wait_for_stdout pipes stdout, inherits stderr, spawns the child process, and after wait_with_output checks output.status.success(). A non-zero exit code (including death by signal, reported as exit code 128+N on Unix) fails the ensure!, prefixed with 'While executing {:?}' describing the command. The child's own diagnostics went to inherited stderr, so the reason is visible in the surrounding log, not in this error.","triggerScenarios":"Any spawned helper binary exiting non-zero: linera-spawn during fungible benchmark setup, linera generate-initial-validator-config, storage initialization (initialize_storage), validator config generation, or linera project new/publish failing validation.","commonSituations":"Port already in use by a previous test run; missing tokio/rocksdb/dynamodb dependency or bad --storage URL; project publish with an invalid linera.toml; the spawned linera binary built from stale code that panicked; PATH resolving to an old binary.","solutions":["Read the child's stderr directly above this error in the log — it contains the actual failure cause","Re-run the failing subcommand manually with the same arguments to reproduce (the {:?} command description in the message shows program and args)","For test-harness failures, clean stale state: kill leftover processes and remove the temporary DB/wallet dirs","If the binary panicked, rebuild (cargo build) and confirm versions match between spawner and child"],"exampleFix":"// before\nlet stdout = cmd.spawn_and_wait_for_stdout().await?; // exit code 1, cause hidden\n\n// after (capture stderr so the cause travels with the error)\nlet out = cmd.output().await?;\nif !out.status.success() {\n    anyhow::bail!(\n        \"command failed ({}): {}\",\n        out.status,\n        String::from_utf8_lossy(&out.stderr)\n    );\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match cmd.spawn_and_wait_for_stdout().await {\n    Ok(stdout) => stdout,\n    Err(e) => {\n        let msg = e.to_string();\n        if msg.contains(\"non-zero error code\") {\n            // child diagnostics are on inherited stderr just above; surface command context\n            tracing::error!(\"child failed: {msg}\");\n        }\n        return Err(e);\n    }\n}","preventionTips":["Run spawned helper binaries manually with the same args when tests fail — the {:?} in the message shows them","Clean up ports and temp state between test runs so children don't fail on bind conflicts","Keep spawner and child binaries built from the same commit"],"tags":["process","subprocess","exit-code","testing","rust","tokio"],"backgroundTag":"non-zero-exit-code","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}