zed-industries/zed · error · anyhow::Error
error running osascript: {}
Error message
error running osascript: {} What it means
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.
Source
Thrown at crates/install_cli/src/install_cli_binary.rs:79
])
.output()
.await?;
if output.status.success() {
return Ok(Some(link_path.into()));
}
// osascript reports "User canceled." (error -128) when the administrator
// prompt is dismissed. Treat that as a cancellation rather than a failure
// so we don't show an error the user already chose to avoid.
let stderr = String::from_utf8_lossy(&output.stderr);
if stderr.contains("User canceled") || stderr.contains("-128") {
return Ok(None);
}
// The privileged write failed, most commonly because the user is not an
// admin.
anyhow::bail!("error running osascript: {}", stderr.trim());
}
pub fn install_cli_binary(window: &mut Window, cx: &mut Context<Workspace>) {
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.";
cx.spawn_in(window, async move |workspace, cx| {
if cfg!(any(target_os = "linux", target_os = "freebsd")) {
let prompt = cx.prompt(
PromptLevel::Warning,
"CLI should already be installed",
Some(LINUX_PROMPT_DETAIL),
&["OK"],
);
cx.background_spawn(prompt).detach();
return Ok(());
}
let path = match install_script(cx.deref()).await {
Ok(Some(path)) => path,View on GitHub (pinned to f4178619ac)
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
Defensive patterns
Strategy: fallback
Try / catch
match run_osascript_privileged(script).await {
Ok(output) if output.status.success() => Ok(Some(())),
Ok(output) => {
let stderr = String::from_utf8_lossy(&output.stderr);
if stderr.contains("User canceled") || stderr.contains("-128") { Ok(None) }
else { manual_install_instructions() } // fallback path, not a crash
}
Err(e) => manual_install_instructions(),
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Corporate managed Macs with restricted /usr/local/bin; standard accounts on shared machines; script errors after the dialog (e.g. target dir missing).
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- Could not determine app path for {}
- Screen share failed: {}
- Failed to get active display list. Result: {result}
- agent.tool_permissions should be an object or null when migr
- failed to change ownership for zed_remote_server via chown:
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/10abe81db4eb41bb.
Report an issue: GitHub.