{"record":{"id":"442c50b2f8a4545f","repo":"BigPizzaV3/CodexPlusPlus","slug":"macos-bundle-binary-points-to-a-shell-script","errorCode":null,"errorMessage":"macOS bundle binary points to a shell script: {}","messagePattern":"macOS bundle binary points to a shell script: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/install/macos.rs","lineNumber":164,"sourceCode":"    if !metadata.is_file() {\n        anyhow::bail!(\n            \"macOS bundle binary is not a regular file: {}\",\n            path.display()\n        );\n    }\n    if metadata.len() < 1024 {\n        anyhow::bail!(\n            \"macOS bundle binary is unexpectedly small: {}\",\n            path.display()\n        );\n    }\n    let mut header = [0_u8; 2];\n    let mut file = fs::File::open(path)?;\n    use std::io::Read;\n    let read = file.read(&mut header)?;\n    if read == header.len() && header == *b\"#!\" {\n        anyhow::bail!(\n            \"macOS bundle binary points to a shell script: {}\",\n            path.display()\n        );\n    }\n    Ok(())\n}\n\n#[cfg(target_os = \"macos\")]\nfn copy_icon(resources: &Path) -> anyhow::Result<()> {\n    let source = std::env::current_exe()\n        .ok()\n        .and_then(|path| path.parent().map(Path::to_path_buf))\n        .map(|path| path.join(\"codex-plus-plus.png\"));\n    if let Some(source) = source.filter(|path| path.exists()) {\n        fs::copy(source, resources.join(\"codex-plus-plus.png\"))?;\n    }\n    Ok(())\n}\n","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/install/macos.rs#L146-L182","documentation":"validate_binary_source reads the first two bytes of the bundle binary and bails if they are \"#!\", i.e. the path is a shell script rather than a Mach-O executable. Bundles must embed a real native binary; a wrapper script breaks Launch Services signing/launching, so install is refused early.","triggerScenarios":"write_bundle -> validate_binary_source on macOS when the source file starts with the shebang magic b\"#!\".","commonSituations":"Repos that ship a launcher shell script named like the binary; build systems placing a wrapper script instead of the compiled binary; users pointing the install at a dev helper script; post-download scripts replaced by text stubs.","solutions":["Point the install at the native Mach-O binary, not the wrapper script","Rebuild the Rust binary with cargo so a real executable is produced","Check `file <path>` — output must be Mach-O, not 'script text executable'","If a wrapper is needed, embed the real binary in the bundle and keep scripts outside Contents/MacOS"],"exampleFix":"// before\nbinary: \"/opt/tools/codex-plus-launcher.sh\"\n// after\nbinary: \"/opt/tools/target/release/codex-plus\"","handlingStrategy":"validation","validationCode":"let mut head = [0u8; 2];\nlet n = std::fs::File::open(&path)?.read(&mut head)?;\nif n == 2 && &head == b\"#!\" {\n    return Err(format!(\"{} is a script, not a native binary\", path.display()));\n}","typeGuard":"fn is_native_binary(p: &Path) -> bool {\n    let mut h = [0u8; 2];\n    std::fs::File::open(p)\n        .and_then(|mut f| std::io::Read::read(&mut f, &mut h))\n        .map(|n| !(n == 2 && &h == b\"#!\"))\n        .unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Use `file <path>` to confirm Mach-O output before bundling","Never name shell wrapper scripts the same as the real binary","Point install options at the cargo-built executable inside target/release"],"tags":["macos","install","validation"],"backgroundTag":"incompatible-source-type","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"}