{"record":{"id":"a214c9438a801695","repo":"zed-industries/zed","slug":"could-not-determine-app-path-for","errorCode":null,"errorMessage":"Could not determine app path for {}","messagePattern":"Could not determine app path for (.+?)","errorType":"console","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/main.rs","lineNumber":1476,"sourceCode":"        }\n    }\n\n    pub(super) fn spawn_channel_cli(\n        channel: release_channel::ReleaseChannel,\n        leftover_args: Vec<String>,\n    ) -> Result<()> {\n        use anyhow::bail;\n\n        let app_path_prompt = format!(\n            \"POSIX path of (path to application \\\"{}\\\")\",\n            channel.display_name()\n        );\n        let app_path_output = Command::new(\"osascript\")\n            .arg(\"-e\")\n            .arg(&app_path_prompt)\n            .output()?;\n        if !app_path_output.status.success() {\n            bail!(\n                \"Could not determine app path for {}\",\n                channel.display_name()\n            );\n        }\n        let app_path = String::from_utf8(app_path_output.stdout)?.trim().to_owned();\n        let cli_path = format!(\"{app_path}/Contents/MacOS/cli\");\n        Command::new(cli_path).args(leftover_args).spawn()?;\n        Ok(())\n    }\n}\n","sourceCodeStart":1458,"sourceCodeEnd":1487,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/cli/src/main.rs#L1458-L1487","documentation":"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.","triggerScenarios":"`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).","commonSituations":"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.","solutions":["Install (or reinstall) the Zed app for the channel you're launching, using the official installer — this registers it with LaunchServices.","Rebuild metadata: `mdimport /Applications/Zed.app`, or reindex with `sudo mdutil -E /`.","Verify the lookup works: `osascript -e 'POSIX path of (path to application \"Zed\")'` (or \"Zed Preview\").","If LaunchServices stays broken, launch the binary directly: `/Applications/Zed.app/Contents/MacOS/zed`."],"exampleFix":"# before: rely on osascript discovery inside the CLI\nzed file.rs   # error: Could not determine app path for Zed\n\n# after: re-register the app with LaunchServices, then retry\nmdimport /Applications/Zed.app\nosascript -e 'POSIX path of (path to application \"Zed\")'  # should print /Applications/Zed.app\nzed file.rs","handlingStrategy":"fallback","validationCode":"// Preflight the AppleScript lookup before relying on it\nlet output = std::process::Command::new(\"osascript\")\n    .args([\"-e\", &format!(\"POSIX path of (path to application \\\"{}\\\")\", display_name)])\n    .output();\nlet ok = output.map(|o| o.status.success()).unwrap_or(false);\nif !ok { /* re-register with mdimport, or fall back to /Applications path */ }","typeGuard":null,"tryCatchPattern":"match launch_via_osascript(channel, args) {\n    Err(err) if err.to_string().contains(\"Could not determine app path\") => {\n        std::process::Command::new(\"/Applications/Zed.app/Contents/MacOS/zed\")\n            .args(args).spawn()\n    }\n    result => result,\n}","preventionTips":["Install Zed via the official installer so LaunchServices registers the app.","After moving Zed.app, run `mdimport /Applications/Zed.app` to refresh metadata.","Keep a direct binary path fallback (`.../Contents/MacOS/zed`) for automation scripts."],"tags":["cli","macos","osascript","launchservices","app-path"],"backgroundTag":"app-path-resolution-failed","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"}