BigPizzaV3/CodexPlusPlus · error · anyhow::Error
macOS Launch Services 无法启动 bundle
Error message
macOS Launch Services 无法启动 bundle {bundle_id}:{detail} What it means
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.
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
Example fix
// before: running from target/debug with no companion binary alongside // spawn_companion falls back to companion_binary_path_from_exe and bails // after: install bundles or build so the fallback exists cargo build --release && ./target/release/codex-plus install
Defensive patterns
Strategy: fallback
Validate before calling
let exe = std::env::current_exe()?;
let fallback = companion_binary_path_from_exe(&exe, binary);
if !fallback.exists() {
eprintln!("companion binary missing at {}; run install first", fallback.display());
} Try / catch
match spawn_companion(binary) {
Ok(child) => { /* started */ }
Err(e) if e.to_string().starts_with("macOS Launch Services") => {
eprintln!("bundle launch failed: {e}; reinstall bundles or build companion binary");
}
Err(e) => return Err(e.into()),
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/dfd93bb6e78f4f3c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/install/mod.rs:290
.collect::<Vec<OsString>>();
#[cfg(target_os = "macos")]
{
let exe = std::env::current_exe().unwrap_or_else(|_| PathBuf::from("."));
if let Some(bundle_id) = macos_companion_bundle_identifier_from_exe(&exe, binary) {
let launch_result = Command::new("/usr/bin/open")
.args(["-n", "-b", bundle_id, "--args"])
.args(&args)
.status();
if launch_result.as_ref().is_ok_and(|status| status.success()) {
return Ok(format!("bundle:{bundle_id}"));
}
let fallback = companion_binary_path_from_exe(&exe, binary);
if !fallback.exists() {
let detail = launch_result
.map(|status| status.to_string())
.unwrap_or_else(|error| error.to_string());
anyhow::bail!("macOS Launch Services 无法启动 bundle {bundle_id}:{detail}");
}
}
}
let path = companion_binary_path(binary);
let mut command = Command::new(&path);
command.args(&args);
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
command.creation_flags(crate::windows_create_no_window());
}
command
.spawn()
.map_err(|error| anyhow::anyhow!("无法启动 {}:{error}", path.to_string_lossy()))?;
Ok(path.to_string_lossy().to_string())
}
View on GitHub (pinned to b1ed92e5e4)