{"record":{"id":"ad5db427e41b38b7","repo":"zed-industries/zed","slug":"cannot-find-app-bundle-containing-cli-path","errorCode":null,"errorMessage":"cannot find app bundle containing {cli_path:?}","messagePattern":"cannot find app bundle containing (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/main.rs","lineNumber":1309,"sourceCode":"        #[serde(rename = \"CFBundleShortVersionString\")]\n        bundle_short_version_string: String,\n    }\n\n    enum Bundle {\n        App {\n            app_bundle: PathBuf,\n            plist: InfoPlist,\n        },\n        LocalPath {\n            executable: PathBuf,\n        },\n    }\n\n    fn locate_bundle() -> Result<PathBuf> {\n        let cli_path = std::env::current_exe()?.canonicalize()?;\n        let mut app_path = cli_path.clone();\n        while app_path.extension() != Some(OsStr::new(\"app\")) {\n            anyhow::ensure!(\n                app_path.pop(),\n                \"cannot find app bundle containing {cli_path:?}\"\n            );\n        }\n        Ok(app_path)\n    }\n\n    impl Detect {\n        pub fn detect(path: Option<&Path>) -> anyhow::Result<impl InstalledApp> {\n            let bundle_path = if let Some(bundle_path) = path {\n                bundle_path\n                    .canonicalize()\n                    .with_context(|| format!(\"Args bundle path {bundle_path:?} canonicalization\"))?\n            } else {\n                locate_bundle().context(\"bundle autodiscovery\")?\n            };\n\n            match bundle_path.extension().and_then(|ext| ext.to_str()) {","sourceCodeStart":1291,"sourceCodeEnd":1327,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/cli/src/main.rs#L1291-L1327","documentation":"On macOS, the CLI's locate_bundle() walks up from the canonicalized path of the running executable looking for a directory with an .app extension. It errors when the binary is not inside any application bundle, because the CLI needs the bundle (and its Info.plist) to launch the right Zed app.","triggerScenarios":"Running a `cli`/`zed` binary that was copied out of Zed.app, moved to /usr/local/bin as a real file instead of a symlink, or executed from a build target directory outside a bundle.","commonSituations":"Homebrew or manual installs where the binary was copied rather than symlinked; developers running target/release/cli from a source checkout; CI runners invoking a standalone binary.","solutions":["Symlink the bundled CLI instead of copying it: `ln -s /Applications/Zed.app/Contents/MacOS/cli /usr/local/bin/zed`","Reinstall Zed from the official .dmg so the CLI stays inside the bundle","Verify with `readlink -f $(which zed)` that the resolved path ends in `.app/Contents/MacOS/cli`"],"exampleFix":"# before (copied binary, bundle walk fails)\ncp /Applications/Zed.app/Contents/MacOS/cli /usr/local/bin/zed\n\n# after (symlink resolves back into the bundle)\nln -s /Applications/Zed.app/Contents/MacOS/cli /usr/local/bin/zed","handlingStrategy":"validation","validationCode":"# verify the CLI resolves inside a bundle before use\nresolved=$(readlink -f \"$(command -v zed)\")\ncase \"$resolved\" in\n  *.app/Contents/MacOS/*) ;;\n  *) echo \"zed binary is outside an app bundle: $resolved\" >&2; exit 2 ;;\nesac\nzed \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install the CLI as a symlink into the bundle, never a copy","Automate installs via the official dmg or script so layout stays correct","After macOS app updates, confirm the symlink still points at the new bundle"],"tags":["macos","cli","app-bundle","installation"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}