{"record":{"id":"10abe81db4eb41bb","repo":"zed-industries/zed","slug":"error-running-osascript","errorCode":null,"errorMessage":"error running osascript: {}","messagePattern":"error running osascript: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/install_cli/src/install_cli_binary.rs","lineNumber":79,"sourceCode":"        ])\n        .output()\n        .await?;\n\n    if output.status.success() {\n        return Ok(Some(link_path.into()));\n    }\n\n    // osascript reports \"User canceled.\" (error -128) when the administrator\n    // prompt is dismissed. Treat that as a cancellation rather than a failure\n    // so we don't show an error the user already chose to avoid.\n    let stderr = String::from_utf8_lossy(&output.stderr);\n    if stderr.contains(\"User canceled\") || stderr.contains(\"-128\") {\n        return Ok(None);\n    }\n\n    // The privileged write failed, most commonly because the user is not an\n    // admin.\n    anyhow::bail!(\"error running osascript: {}\", stderr.trim());\n}\n\npub fn install_cli_binary(window: &mut Window, cx: &mut Context<Workspace>) {\n    const LINUX_PROMPT_DETAIL: &str = \"If you installed Zed from our official release add ~/.local/bin to your PATH.\\n\\nIf you installed Zed from a different source like your package manager, then you may need to create an alias/symlink manually.\\n\\nDepending on your package manager, the CLI might be named zeditor, zedit, zed-editor or something else.\";\n\n    cx.spawn_in(window, async move |workspace, cx| {\n        if cfg!(any(target_os = \"linux\", target_os = \"freebsd\")) {\n            let prompt = cx.prompt(\n                PromptLevel::Warning,\n                \"CLI should already be installed\",\n                Some(LINUX_PROMPT_DETAIL),\n                &[\"OK\"],\n            );\n            cx.background_spawn(prompt).detach();\n            return Ok(());\n        }\n        let path = match install_script(cx.deref()).await {\n            Ok(Some(path)) => path,","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/install_cli/src/install_cli_binary.rs#L61-L97","documentation":"install_cli's macOS privileged-install path runs osascript with 'with administrator privileges' to symlink the CLI into /usr/local/bin. When the script fails and the stderr is not the 'User canceled.'/-128 dismissal case (which returns Ok(None)), it bails with the raw AppleScript stderr. The most common cause is the account not being an administrator, so the prompt cannot grant the write.","triggerScenarios":"A standard (non-admin) macOS user approving the privilege dialog, an admin password entered incorrectly, SIP or MDM policy blocking writes to /usr/local/bin, or osascript itself erroring out mid-script.","commonSituations":"Corporate managed Macs with restricted /usr/local/bin; standard accounts on shared machines; script errors after the dialog (e.g. target dir missing).","solutions":["Install manually: sudo mkdir -p /usr/local/bin && sudo ln -s \"/path/to/Zed.app/Contents/MacOS/cli\" /usr/local/bin/zed","Ensure the account is an administrator, or have an admin run the install once","If /usr/local/bin is restricted by MDM, target a user-writable PATH dir like ~/bin or ~/.local/bin instead","Report remaining stderr verbatim — AppleScript messages name the failing step"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match run_osascript_privileged(script).await {\n    Ok(output) if output.status.success() => Ok(Some(())),\n    Ok(output) => {\n        let stderr = String::from_utf8_lossy(&output.stderr);\n        if stderr.contains(\"User canceled\") || stderr.contains(\"-128\") { Ok(None) }\n        else { manual_install_instructions() } // fallback path, not a crash\n    }\n    Err(e) => manual_install_instructions(),\n}","preventionTips":["Keep the -128/'User canceled' exemption so dismissals are not errors","Always offer the manual sudo ln -s command alongside the privileged prompt","Detect non-admin accounts up front and skip straight to the manual instructions"],"tags":["macos","osascript","permissions","cli-install","privileges"],"backgroundTag":"permission-denied","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}