zed-industries/zed · error · anyhow::Error

Could not determine app path for {}

Error message

Could not determine app path for {}

What it means

On macOS, the Zed CLI launches the app binary by first asking AppleScript (`osascript -e 'POSIX path of (path to application "<name>")'`) where the application for the current channel (Zed / Zed Preview / Zed Nightly) is installed. If the osascript command exits non-zero, the CLI cannot locate the app and bails. The lookup depends on LaunchServices/Spotlight metadata knowing about the app.

Source

Thrown at crates/cli/src/main.rs:1476

        }
    }

    pub(super) fn spawn_channel_cli(
        channel: release_channel::ReleaseChannel,
        leftover_args: Vec<String>,
    ) -> Result<()> {
        use anyhow::bail;

        let app_path_prompt = format!(
            "POSIX path of (path to application \"{}\")",
            channel.display_name()
        );
        let app_path_output = Command::new("osascript")
            .arg("-e")
            .arg(&app_path_prompt)
            .output()?;
        if !app_path_output.status.success() {
            bail!(
                "Could not determine app path for {}",
                channel.display_name()
            );
        }
        let app_path = String::from_utf8(app_path_output.stdout)?.trim().to_owned();
        let cli_path = format!("{app_path}/Contents/MacOS/cli");
        Command::new(cli_path).args(leftover_args).spawn()?;
        Ok(())
    }
}

View on GitHub (pinned to f4178619ac)

Solutions

  1. Install (or reinstall) the Zed app for the channel you're launching, using the official installer — this registers it with LaunchServices.
  2. Rebuild metadata: `mdimport /Applications/Zed.app`, or reindex with `sudo mdutil -E /`.
  3. Verify the lookup works: `osascript -e 'POSIX path of (path to application "Zed")'` (or "Zed Preview").
  4. If LaunchServices stays broken, launch the binary directly: `/Applications/Zed.app/Contents/MacOS/zed`.

Example fix

# before: rely on osascript discovery inside the CLI
zed file.rs   # error: Could not determine app path for Zed

# after: re-register the app with LaunchServices, then retry
mdimport /Applications/Zed.app
osascript -e 'POSIX path of (path to application "Zed")'  # should print /Applications/Zed.app
zed file.rs
Defensive patterns

Strategy: fallback

Validate before calling

// Preflight the AppleScript lookup before relying on it
let output = std::process::Command::new("osascript")
    .args(["-e", &format!("POSIX path of (path to application \"{}\")", display_name)])
    .output();
let ok = output.map(|o| o.status.success()).unwrap_or(false);
if !ok { /* re-register with mdimport, or fall back to /Applications path */ }

Try / catch

match launch_via_osascript(channel, args) {
    Err(err) if err.to_string().contains("Could not determine app path") => {
        std::process::Command::new("/Applications/Zed.app/Contents/MacOS/zed")
            .args(args).spawn()
    }
    result => result,
}

Prevention

When it happens

Trigger: `osascript` fails when LaunchServices has no record of an app named with the channel's display name: the app was never registered (copied manually instead of installed), the app was moved/deleted, Spotlight indexing is disabled or stale (mdutil), or the channel name doesn't match any installed app (e.g., CLI channel set to Preview but only stable installed).

Common situations: Zed.app uninstalled or moved but the `zed` CLI still on PATH; fresh macOS or restored-from-backup machine where LaunchServices metadata is missing; Spotlight/Volumes indexing disabled; user only installed one channel but the CLI targets another.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/a214c9438a801695. Report an issue: GitHub.