{"record":{"id":"dfd93bb6e78f4f3c","repo":"BigPizzaV3/CodexPlusPlus","slug":"macos-launch-services-bundle-bundle-id-det","errorCode":null,"errorMessage":"macOS Launch Services 无法启动 bundle {bundle_id}：{detail}","messagePattern":"macOS Launch Services 无法启动 bundle (.+?)：(.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/install/mod.rs","lineNumber":290,"sourceCode":"        .collect::<Vec<OsString>>();\n\n    #[cfg(target_os = \"macos\")]\n    {\n        let exe = std::env::current_exe().unwrap_or_else(|_| PathBuf::from(\".\"));\n        if let Some(bundle_id) = macos_companion_bundle_identifier_from_exe(&exe, binary) {\n            let launch_result = Command::new(\"/usr/bin/open\")\n                .args([\"-n\", \"-b\", bundle_id, \"--args\"])\n                .args(&args)\n                .status();\n            if launch_result.as_ref().is_ok_and(|status| status.success()) {\n                return Ok(format!(\"bundle:{bundle_id}\"));\n            }\n            let fallback = companion_binary_path_from_exe(&exe, binary);\n            if !fallback.exists() {\n                let detail = launch_result\n                    .map(|status| status.to_string())\n                    .unwrap_or_else(|error| error.to_string());\n                anyhow::bail!(\"macOS Launch Services 无法启动 bundle {bundle_id}：{detail}\");\n            }\n        }\n    }\n\n    let path = companion_binary_path(binary);\n    let mut command = Command::new(&path);\n    command.args(&args);\n    #[cfg(windows)]\n    {\n        use std::os::windows::process::CommandExt;\n        command.creation_flags(crate::windows_create_no_window());\n    }\n    command\n        .spawn()\n        .map_err(|error| anyhow::anyhow!(\"无法启动 {}：{error}\", path.to_string_lossy()))?;\n    Ok(path.to_string_lossy().to_string())\n}\n","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/install/mod.rs#L272-L308","documentation":"spawn_companion on macOS first tries to launch the companion binary through Launch Services (open/activate the app bundle). If that launch fails or returns a non-success status AND the fallback companion binary next to the current exe does not exist, it bails with this message embedding the bundle id and the launch failure detail. It means the manager could not be started via either path.","triggerScenarios":"open_or_activate_manager -> spawn_companion on macOS when `open`/Launch Services errors or returns a failing exit status and companion_binary_path_from_exe(&exe, binary) does not exist on disk.","commonSituations":"App bundle moved/renamed or not installed so the bundle id is unknown to Launch Services; quarantined/un-signed binary rejected by Gatekeeper; running from a cargo target dir where the companion binary wasn't built/copied next to the exe; bundle Info.plist CFBundleIdentifier mismatch.","solutions":["Run `cargo build` / reinstall so the companion binary exists next to the executable, then retry","Re-register the bundle with Launch Services (`lsregister -f <path to .app>`)","Inspect the {detail} in the message for the underlying Launch Services error","Reinstall the app bundles (install_entrypoints) so bundle id and Info.plist are correct","Clear quarantine: `xattr -dr com.apple.quarantine <App.app>` if Gatekeeper blocks it"],"exampleFix":"// before: running from target/debug with no companion binary alongside\n// spawn_companion falls back to companion_binary_path_from_exe and bails\n// after: install bundles or build so the fallback exists\ncargo build --release && ./target/release/codex-plus install","handlingStrategy":"fallback","validationCode":"let exe = std::env::current_exe()?;\nlet fallback = companion_binary_path_from_exe(&exe, binary);\nif !fallback.exists() {\n    eprintln!(\"companion binary missing at {}; run install first\", fallback.display());\n}","typeGuard":null,"tryCatchPattern":"match spawn_companion(binary) {\n    Ok(child) => { /* started */ }\n    Err(e) if e.to_string().starts_with(\"macOS Launch Services\") => {\n        eprintln!(\"bundle launch failed: {e}; reinstall bundles or build companion binary\");\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Ensure the companion binary is built/copied next to the current executable","Reinstall app bundles so Launch Services knows the bundle id","Re-register bundles with lsregister after moving the .app","Clear Gatekeeper quarantine on downloaded builds"],"tags":["macos","launch-services","process-spawn"],"backgroundTag":"command-not-found","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}