{"record":{"id":"9b049e44a41c887c","repo":"gitbutlerapp/gitbutler","slug":"cliinstallcancelled","errorCode":"CliInstallCancelled","errorMessage":"Administrator authorization was cancelled","messagePattern":"Administrator authorization was cancelled","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/but-action/src/cli.rs","lineNumber":233,"sourceCode":"        return \"gitbutler-cli-installed\"\n    on error messageText number errorNumber\n        if errorNumber is -128 then return \"gitbutler-cli-install-cancelled\"\n        error messageText number errorNumber\n    end try\nend run\n\"#;\n\n#[cfg(any(target_os = \"macos\", all(test, unix)))]\nfn check_cli_install_output(output: std::process::Output) -> anyhow::Result<()> {\n    anyhow::ensure!(\n        output.status.success(),\n        \"CLI installation failed ({}): {}\",\n        output.status,\n        String::from_utf8_lossy(&output.stderr).trim()\n    );\n    if output.stdout == b\"gitbutler-cli-install-cancelled\\n\" {\n        return Err(\n            anyhow!(\"Administrator authorization was cancelled\").context(ErrorContext::new_static(\n                Code::CliInstallCancelled,\n                \"CLI install cancelled\",\n            )),\n        );\n    }\n    anyhow::ensure!(\n        output.stdout == b\"gitbutler-cli-installed\\n\",\n        \"Unexpected CLI installer response\"\n    );\n    Ok(())\n}\n\n#[cfg(target_os = \"macos\")]\npub fn auto_fix_broken_but_cli_symlink() {\n    let Ok(absolute_link_destination) = std::fs::read_link(UNIX_LINK_PATH) else {\n        return;\n    };\n    if absolute_link_destination.exists() {","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-action/src/cli.rs#L215-L251","documentation":"When the elevated install AppleScript prints 'gitbutler-cli-install-cancelled' (user clicked Cancel on the macOS administrator-privilege prompt, AppleScript error -128 userCanceled), check_cli_install_output maps it to this error carrying ErrorContext code CliInstallCancelled. It deliberately distinguishes an intentional user cancellation from a genuine script failure so callers can treat it as a no-op rather than a bug.","triggerScenarios":"install_cli_link_escalated triggers the 'GitButler needs administrator access...' password dialog and the user clicks Cancel / authenticates unsuccessfully by cancelling; the script returns 'gitbutler-cli-install-cancelled'.","commonSituations":"User changes their mind about entering an admin password during CLI setup; the prompt is dismissed with Escape; enterprise policy blocks the privilege escalation dialog.","solutions":["Nothing is broken — rerun the CLI install and click 'OK' after entering administrator credentials.","Avoid the admin prompt entirely by using the per-user install mode (CurrentUserOnly), which installs the symlink into a user-writable PATH directory.","If the code matches on this error, handle Code::CliInstallCancelled as an expected, user-initiated abort — do not surface it as a failure toast."],"exampleFix":"// before\nmatch result { Err(e) => show_error(e), ... }\n\n// after\nmatch result {\n    Err(e) if e.error_code() == Code::CliInstallCancelled => info!(\"install cancelled by user\"),\n    Err(e) => show_error(e),\n    Ok(()) => {}\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn is_cancelled(e: &but_error::Error) -> bool { e.get_code() == Code::CliInstallCancelled }","tryCatchPattern":"match install_cli_link_escalated(...) {\n    Err(e) if e.get_code() == Code::CliInstallCancelled => {\n        tracing::info!(\"user cancelled admin authorization; not an error\");\n    }\n    Err(e) => report(e),\n    Ok(()) => {}\n}","preventionTips":["Offer the CurrentUserOnly install mode to avoid the admin password prompt entirely.","Treat Code::CliInstallCancelled as an expected outcome in UI/automation, never as a failure alert.","Inform users up front that an administrator prompt will appear."],"tags":["macos","user-cancelled","cli-installation","privilege-escalation"],"backgroundTag":"authentication-required","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}