#29

Bug: "zsh: killed" on macOS Apple Silicon (M4) due to corrupted Mach-O signature in compiled binary

OpenAnthony2ccopened 6mo ago

OS: macOS 15.7.4 CPU Architecture: Apple Silicon M4 Installation Method: Quick install script After successfully installing the project via the quick install instructions, running the CLI results in an immediate crash: zsh: killed free-code /login

When inspecting the underlying cli-dev file using the file command, it shows up correctly as a native executable: Mach-O 64-bit executable arm64. However, when trying to manually apply an ad-hoc signature to bypass Gatekeeper (codesign --force --deep -s - cli-dev), the built-in codesign tool rejects the file: cli-dev: invalid or unsupported format for signature.

Root Cause Analysis It appears that packaging the CLI with bun build --compile introduces structural corruption to the Mach-O binary headers / code-signing layout on modern Apple Silicon architectures. Because the macOS kernel strictly enforces code signing, it sees the malformed signature layout and instantly terminates the process with SIGKILL. The file structure is so malformed that standard signing utilities refuse to operate on it.

Temporary Workaround For anyone encountering this on M-series Macs, you can bypass the compiled binary entirely and use bun to execute the source file directly. Delete the broken binary & Create a script file ~/free-code/cli.sh containing: #!/bin/bash cd ~/free-code exec bun run ./src/entrypoints/cli.tsx "$@" And then make it executable and re-link: chmod +x ~/free-code/cli.sh ln -s ~/free-code/cli.sh ~/free-code/cli-dev

Activity

1
fozt6mo ago

Additional note on the workaround

The script in the workaround uses cd ~/free-code, which changes your working directory on every invocation. If you want free-code to operate on the current directory (which is the expected behavior for a CLI tool), use the full path to cli.tsx instead:

#!/bin/bash
exec bun run ~/free-code/src/entrypoints/cli.tsx "$@"

Then re-link:

chmod +x ~/free-code/cli.sh
ln -sf ~/free-code/cli.sh ~/free-code/cli-dev

This way the tool runs in whatever directory you call it from, rather than always defaulting to ~/free-code.