Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

How to Fix Bun v1.3.12 Based Opencode Got Killed: 9 After Bun Turbo Build

Permalink

New bun 1.3.12 release but I got:

$ ./opencode --version
Killed: 9

In fact, the binary was fine. The code signature was not.

Diagnosis

A quick check with codesign revealed the real culprit:

$ codesign -vv ./opencode
./opencode: invalid or unsupported format for signature
In architecture: arm64

On Apple Silicon, macOS enforces code signing strictly. A malformed or corrupt LC_CODE_SIGNATURE load command will cause the kernel to terminate the process immediately with SIGKILL (Killed: 9)—before a single line of your code runs.

You can confirm the signature load command exists with otool:

$ otool -l ./opencode | grep LC_CODE_SIGNATURE
cmd LC_CODE_SIGNATURE

The Fix

Remove the broken signature and replace it with a local ad-hoc signature:

codesign --remove-signature ./opencode
codesign --sign - --force ./opencode

Then verify:

$ codesign -vv ./opencode
./opencode: valid on disk
./opencode: satisfies its Designated Requirement
$ ./opencode --version
0.0.0-eric_dev-202604120639

Comments