{"record":{"id":"53e73adbd8d0125c","repo":"Morganamilo/paru","slug":"pacman-stderr","errorCode":null,"errorMessage":"{pacman stderr}","messagePattern":"\\{pacman stderr\\}","errorType":"console","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/install.rs","lineNumber":1560,"sourceCode":"}\n\nfn set_install_reason<S: AsRef<str>>(config: &Config, reason: &str, pkgs: &[S]) -> Result<()> {\n    let alpm = config.new_alpm()?;\n    let db = alpm.localdb();\n\n    let pkgs = pkgs\n        .iter()\n        .map(|s| s.as_ref())\n        .filter(|p| db.pkg(*p).is_ok());\n\n    let mut args = config.pacman_globals();\n    args.op(\"database\").arg(reason).targets(pkgs);\n    if args.targets.is_empty() {\n        return Ok(());\n    }\n\n    let output = exec::pacman_output(config, &args)?;\n    ensure!(\n        output.status.success(),\n        \"{}\",\n        String::from_utf8_lossy(&output.stderr)\n    );\n    Ok(())\n}\n\nfn pre_build_command(config: &Config, dir: &Path, base: &str, version: &str) -> Result<()> {\n    if let Some(ref pb_cmd) = config.pre_build_command {\n        let mut cmd = Command::new(\"sh\");\n        cmd.env(\"PKGBASE\", base)\n            .env(\"VERSION\", version)\n            .current_dir(dir)\n            .arg(\"-c\")\n            .arg(pb_cmd);\n        exec::command(&mut cmd)?;\n    }\n    Ok(())","sourceCodeStart":1542,"sourceCodeEnd":1578,"githubUrl":"https://github.com/Morganamilo/paru/blob/9ac3578807a87858651e81a02586ceb947686e7c/src/install.rs#L1542-L1578","documentation":"set_install_reason runs `pacman -D --asdeps/--asexplicit` to mark installed packages and, when the command fails, surfaces pacman's stderr verbatim as the error. The message content is whatever pacman printed, e.g. 'error: target not found: <pkg>'.","triggerScenarios":"paru -S --asdeps (or --asexp) on packages, and exec::pacman_output returns a non-success status for `pacman -D database` (e.g. target package not installed or not owned by pacman).","commonSituations":"Marking packages as deps when a package was removed concurrently or installed outside pacman; permission/db lock issues also surface here via stderr.","solutions":["Read the stderr text in the error: it names the exact pacman failure (usually 'target not found')","Ensure the packages exist in the local pacman database before using --asdeps/--asexp","Re-run after resolving pacman db locks or syncing: sudo pacman -D --asdeps <pkg> directly to see full output"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check the package exists in the local db before --asdeps\npacman -Qi \"$pkg\" >/dev/null 2>&1 || echo \"not installed: $pkg\"","typeGuard":null,"tryCatchPattern":"match set_install_reason(config, reason, pkgs) {\n    Err(e) => eprintln!(\"pacman -D failed: {}\", e), // stderr text names the target\n    Ok(()) => {}\n}","preventionTips":["Confirm packages are installed via pacman before changing install reason","Run pacman -D directly to see full stderr when in doubt","Avoid concurrent pacman operations that could remove targets mid-run"],"tags":["pacman","process","packages"],"backgroundTag":"http-error-response","analyzedSha":"9ac3578807a87858651e81a02586ceb947686e7c","analyzedAt":"2026-09-12T04:57:59.861Z","contentChangedAt":"2026-09-12T04:57:59.861Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}