{"record":{"id":"170ca4aa69fc666d","repo":"sigoden/aichat","slug":"err-170ca4","errorCode":null,"errorMessage":"{err}","messagePattern":"\\{err\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/utils/command.rs","lineNumber":141,"sourceCode":"            v\n        })\n        .collect();\n    let cmd_eval = shell_words::join(&cmd_args);\n    debug!(\"run `{cmd_eval}`\");\n    let (cmd, args) = cmd_args.split_at(1);\n    let cmd = &cmd[0];\n    if use_stdout {\n        let (success, stdout, stderr) =\n            run_command_with_output(cmd, args, None).with_context(|| {\n                format!(\"Unable to run `{cmd_eval}`, Perhaps '{cmd}' is not installed?\")\n            })?;\n        if !success {\n            let err = if !stderr.is_empty() {\n                stderr\n            } else {\n                format!(\"The command `{cmd_eval}` exited with non-zero.\")\n            };\n            bail!(\"{err}\")\n        }\n        Ok(stdout)\n    } else {\n        let status = run_command(cmd, args, None).with_context(|| {\n            format!(\"Unable to run `{cmd_eval}`, Perhaps '{cmd}' is not installed?\")\n        })?;\n        if status != 0 {\n            bail!(\"The command `{cmd_eval}` exited with non-zero.\")\n        }\n        let contents = std::fs::read_to_string(&outpath)\n            .context(\"Failed to read file generated by the loader\")?;\n        Ok(contents)\n    }\n}\n\npub fn edit_file(editor: &str, path: &Path) -> Result<()> {\n    let mut child = Command::new(editor).arg(path).spawn()?;\n    child.wait()?;","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/utils/command.rs#L123-L159","documentation":"run_loader_command executes an external loader command and, if it exits non-zero, bails with the command's stderr (or a generic non-zero-exit message when stderr is empty). This propagates the external tool's failure text as the library error.","triggerScenarios":"Any load operation that shells out to a configured loader (URL loader, protocol-path loader, recursive URL loader, or a custom loader command) when that command exits with a non-zero status.","commonSituations":"Loader binary not installed or not on PATH; wrong arguments in the loader config; loader failing on a bad URL/auth; sandbox blocking the command.","solutions":["Run the failing command manually to see its stderr and fix the underlying cause","Install or update the loader binary referenced by the config","Correct the loader command/args in the configuration file","If stderr was empty, add logging to the loader to expose why it exits non-zero","Verify the URL/path input is valid for that loader"],"exampleFix":"// before: loader command missing required arg\nloader = [\"yt-dlp\"]\n// after\nloader = [\"yt-dlp\", \"--dump-json\"]","handlingStrategy":"try-catch","validationCode":"const { execFileSync } = require('child_process');\nfunction loaderAvailable(cmd) {\n  try { execFileSync(cmd, ['--version'], { stdio: 'ignore' }); return true; }\n  catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const docs = await loadUrl(url);\n} catch (e) {\n  // e.message contains loader stderr; run the command manually to debug\n  console.error('loader failed:', e.message);\n}","preventionTips":["Install loader binaries and verify with --version in CI","Test loader commands manually before adding them to config","Keep loader stderr informative"],"tags":["external-command","loader","process","cli"],"backgroundTag":"git-command-failed","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}