{"record":{"id":"fb0111b39d7ab817","repo":"zeroclaw-labs/zeroclaw","slug":"editor-exited-with-non-zero-status","errorCode":null,"errorMessage":"{editor} exited with non-zero status","messagePattern":"(.+?) exited with non-zero status","errorType":"console","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/skills/mod.rs","lineNumber":1237,"sourceCode":"        let prompt: String = dialoguer::Input::new()\n            .with_prompt(\"Skill description (what it does, when to use it)\")\n            .interact_text()?;\n        if prompt.trim().is_empty() {\n            anyhow::bail!(\"description must not be empty\");\n        }\n        Ok(prompt)\n    } else {\n        anyhow::bail!(\"--description is required when stdin is not a TTY\");\n    }\n}\n\nfn open_in_editor(path: &std::path::Path) -> Result<()> {\n    let Some(editor) = editor_from_env_or_path() else {\n        anyhow::bail!(\"no editor found; set VISUAL or EDITOR\");\n    };\n    let status = std::process::Command::new(&editor).arg(path).status()?;\n    if !status.success() {\n        anyhow::bail!(\"{editor} exited with non-zero status\");\n    }\n    Ok(())\n}\n\nfn editor_from_env_or_path() -> Option<String> {\n    std::env::var(\"VISUAL\")\n        .ok()\n        .filter(|value| !value.trim().is_empty())\n        .or_else(|| {\n            std::env::var(\"EDITOR\")\n                .ok()\n                .filter(|value| !value.trim().is_empty())\n        })\n        .or_else(|| {\n            fallback_editors()\n                .iter()\n                .copied()\n                .find(|candidate| executable_on_path(candidate))","sourceCodeStart":1219,"sourceCodeEnd":1255,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/src/skills/mod.rs#L1219-L1255","documentation":"The chosen editor was launched successfully but its process returned a non-zero exit status, so the CLI treats the edit session as failed and refuses to continue. The editor binary name is included in the message.","triggerScenarios":"Quitting vim with :cq (deliberate non-zero exit); editor crashing on launch; the editor unable to open the path (permissions, bad path); GUI editors that fork and return immediately with a status; a mistyped VISUAL/EDITOR value that resolves to a failing command.","commonSituations":"Users aborting the editor with an error exit; wrapper scripts set as EDITOR that exit non-zero; editors needing a TTY run without one; VS Code/GUI editors used as EDITOR in non-blocking mode.","solutions":["Re-run the command and exit the editor normally (save then quit, e.g. :wq in vim)","Verify the editor works standalone on the file: $VISUAL /path/to/file","Use a terminal-based blocking editor (nano, vim) for VISUAL/EDITOR instead of forking GUI editors","If the editor cannot work in this context, edit the generated file manually at the path the command printed"],"exampleFix":"# before\nexport EDITOR='code --wait'  # returns before save in some setups\n# after\nexport EDITOR=vim  # blocking terminal editor, exit :wq to continue","handlingStrategy":"try-catch","validationCode":"if [ -n \"${VISUAL:-${EDITOR:-}}\" ]; then\n  # smoke-test the editor exits 0 on a scratch file before the real run\n  f=$(mktemp); \"${VISUAL:-$EDITOR}\" \"$f\" </dev/null >/dev/null 2>&1 || { echo 'editor unusable' >&2; exit 1; }; rm -f \"$f\"\nfi","typeGuard":null,"tryCatchPattern":"match err.chain().to_string() containing \"exited with non-zero status\" -> report which editor failed, print the file path so the user can edit it manually, and exit non-zero without retry","preventionTips":["Exit editors with a normal save+quit (:wq, Ctrl+O/Ctrl+X), never :cq","Point VISUAL/EDITOR at a blocking terminal editor","Verify wrapper scripts used as EDITOR propagate the child editor's exit status"],"tags":["editor","subprocess","exit-code","cli","skills","rust"],"backgroundTag":"subprocess-nonzero-exit","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}