You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 7, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 7, 2026. It is now read-only.
[Bug] Codex agent fails to start on macOS x64 (v0.0.84) — missing bundled ACP binary #205
After installing 1Code v0.0.84 on macOS x64 and attempting to use the Codex agent, the app immediately fails with two consecutive errors.
Error 1 — Missing bundled CLI
[codex] Bundled Codex CLI not found at /Applications/1Code.app/Contents/Resources/bin/codex.
Binary is missing from bundled resources.
The directory /Applications/1Code.app/Contents/Resources/bin/ does not exist at all in the installed bundle.
Error 2 — Missing ACP native module
After attempting a workaround (manual symlink), the next error appears:
Cannot find module '@zed-industries/codex-acp-darwin-x64/bin/codex-acp'
Require stack:
This indicates that the native ACP package @zed-industries/codex-acp-darwin-x64 is not bundled inside app.asar.
Steps to Reproduce
Download and install 1Code-0.0.84.dmg (macOS x64 build).
Open 1Code and attempt to activate/use the Codex agent.
Observe the errors above in the app logs / console.
Expected Behavior
The Codex agent should start successfully. The bundled binary at /Applications/1Code.app/Contents/Resources/bin/codex
and the native module @zed-industries/codex-acp-darwin-x64 should be present in the release package for macOS x64.
Actual Behavior
Contents/Resources/bin/ directory is missing entirely.
@zed-industries/codex-acp-darwin-x64 is not bundled inside app.asar.
Workaround via sudo ln -s $(which codex) ... is blocked by macOS SIP (Operation not permitted), so there is no viable manual fix.
Possible Root Cause
It appears the macOS x64 build was packaged without the platform-specific native ACP binaries for Codex. The darwin-arm64 build may not be affected.
Suggested Fix
Ensure @zed-industries/codex-acp-darwin-x64 is included in the app.asar bundled node_modules for the x64 macOS release.
Alternatively, provide a configuration option in the UI to point to an externally installed codex binary path, so users can work around bundling issues without needing to bypass SIP.
The resolveBundledCodexCliPath() function (line 237) looks for the binary at process.resourcesPath/bin/codex in packaged apps. This binary gets placed there via the extraResources config in package.json:166-172:
The binary is downloaded during the release process by scripts/download-codex-binary.mjs, which has explicit darwin-x64 support (line 32-36) — it downloads codex-x86_64-apple-darwin.tar.gz into resources/bin/darwin-x64/codex.
Likely cause: The release script (package.json:27) runs bun run codex:download before bun run package:mac. The codex:download command (line 25) only downloads for the current platform by default. If the release was built on an arm64 Mac, only resources/bin/darwin-arm64/ would be populated, and the x64 build would get an empty bin/ directory (or none at all). The --all flag exists (codex:download:all, line 26) but is not used in the release script.
The resolveCodexAcpBinaryPath() function (line 223) resolves the platform-specific ACP package via require.resolve(). The platform package is determined by getCodexPackageName() (line 188) which correctly maps darwin/x64 to @zed-industries/codex-acp-darwin-x64.
The main @zed-industries/codex-acp package (line 76 in package.json, version 0.9.3) declares these as optional dependencies. The asarUnpack config (package.json:183-184) correctly includes both the wrapper and platform packages:
Likely cause:bun install (or the package manager used during CI) only installs optional native dependencies for the host architecture. When building on an arm64 Mac, @zed-industries/codex-acp-darwin-arm64 gets installed but @zed-industries/codex-acp-darwin-x64 does not. electron-builder then packages only what's in node_modules/, so the x64 build ships without the x64 ACP binary.
Root Cause Summary
Both errors trace back to the same underlying issue: the release is likely built on an arm64 Mac, and cross-architecture dependencies are not installed. The release script in package.json:27 is:
rm -rf release && bun i && bun run claude:download && bun run codex:download && bun run build && bun run package:mac && ...
This runs bun i (installs native deps for host arch only) and codex:download (downloads CLI binary for host platform only), then package:mac builds for botharm64 and x64 targets (package.json:191-193).
Suggested Fix Approach
Codex CLI binary: Change the release script to use codex:download:all (and claude:download:all) instead of the single-platform variants, so resources/bin/darwin-x64/ is populated even when building on arm64.
ACP native module: This is trickier. Options include:
Run npm install --cpu=x64 --os=darwin @zed-industries/codex-acp (or equivalent bun flag) as a pre-build step to force-install cross-arch optional deps.
Use electron-builder's beforeBuild hook or npmRebuild option to ensure platform-specific optional deps are installed for each target arch.
Bundle the ACP binary as an extraResource (similar to the CLI binary) instead of relying on npm optional deps.
Fallback path (addresses the user's suggestion): Adding a UI setting to point to an externally installed codex binary would be a useful workaround for edge cases, but should not replace fixing the bundling.
bun run codex:download && ... && bun run package:mac
codex:download (without --all) calls download-codex-binary.mjs which only downloads the binary for the current platform (scripts/download-codex-binary.mjs:371):
If the release is built on an arm64 Mac (which is likely), only resources/bin/darwin-arm64/codex gets downloaded. The electron-builder config then uses ${platform}-${arch} substitution to copy per-arch binaries:
When building the x64 target, electron-builder looks for resources/bin/darwin-x64/ — which doesn't exist because the download script only fetched darwin-arm64. The extraResources copy silently does nothing (no error on missing source), resulting in the Contents/Resources/bin/ directory being entirely absent from the x64 build.
The @zed-industries/codex-acp wrapper package (v0.9.3) declares all platform variants as optional dependencies (bun.lock:821). When bun install runs on an arm64 Mac, bun correctly skips codex-acp-darwin-x64 because its cpu field doesn't match the host.
electron-builder's asarUnpack config (package.json:184) correctly includes the glob node_modules/@zed-industries/codex-acp-*/**/*, but since the x64 package was never installed to node_modules/, there's nothing to unpack.
At runtime, resolveCodexAcpBinaryPath() (src/main/lib/trpc/routers/codex.ts:223-235) calls require.resolve("@zed-industries/codex-acp-darwin-x64/bin/codex-acp") which fails because the package doesn't exist in the asar.
Fix 1: Download all platform binaries during release
Change the release script in package.json:27 to use codex:download:all instead of codex:download:
-"release": "... bun run claude:download && bun run codex:download && ..."+"release": "... bun run claude:download:all && bun run codex:download:all && ..."
This ensures resources/bin/darwin-x64/codex exists when electron-builder builds the x64 target. The same issue likely applies to claude:download — check if download-claude-binary.mjs has the same single-platform default behavior.
The release:dev script (package.json:28) should get the same treatment.
Fix 2: Force-install all platform-specific codex-acp packages
For the native ACP module, the build needs all platform variants installed in node_modules/ before packaging. Options:
Option A — Add explicit optional dependencies to the project's package.json:
However, bun will still skip packages whose os/cpu don't match the host. So this alone may not suffice.
Option B (Recommended) — Use a pre-package script to explicitly install cross-platform deps:
Add a step in the release script that force-installs the needed platform packages. For example:
bun add --optional @zed-industries/codex-acp-darwin-x64@0.9.3 --force
Or use npm/yarn for this specific install since they may handle cross-platform optional deps differently.
Option C — Use electron-builder's beforePack hook to ensure the target platform's native module is present before each arch build. This is the most robust approach for cross-compilation scenarios.
Fix 3 (Nice-to-have): Add a fallback for external codex binary
As the reporter suggested, add a setting to allow users to specify an external codex binary path. In resolveBundledCodexCliPath() (src/main/lib/trpc/routers/codex.ts:237-260), check for a user-configured path before falling back to the bundled location. This would serve as a workaround for any future bundling issues.
Files to Modify
File
Change
package.json:27-28
Use codex:download:all and claude:download:all in release scripts
package.json (new section)
Add optionalDependencies for all codex-acp platform variants, or add beforePack hook
electron-builder.yml or package.json build section
(Optional) Add beforePack script for cross-platform native module installation
Verification
After fixing, verify by building on an arm64 Mac and checking the x64 output:
# After building
ls -la "release/mac-x64/1Code.app/Contents/Resources/bin/codex"# Should exist and be the x86_64 binary# Check the unpacked asar for codex-acp
ls -la "release/mac-x64/1Code.app/Contents/Resources/app.asar.unpacked/node_modules/@zed-industries/codex-acp-darwin-x64/bin/codex-acp"# Should exist and be the x86_64 native binary
Error 1 — Missing Codex CLI binary is thrown by resolveBundledCodexCliPath() in src/main/lib/trpc/routers/codex.ts:237-260. In packaged apps, it expects the binary at {process.resourcesPath}/bin/codex (line 240). This path is populated by electron-builder's extraResources config in package.json:166-172:
This copies from resources/bin/darwin-x64/ at build time. The binary is downloaded by scripts/download-codex-binary.mjs which fetches from the openai/codex GitHub releases.
Error 2 — Missing ACP native module is thrown when resolveCodexAcpBinaryPath() (codex.ts:223-235) calls require.resolve() for @zed-industries/codex-acp-darwin-x64. The platform-specific package is selected by getCodexPackageName() (codex.ts:188-208).
Root Cause Analysis
There are two separate bundling issues:
1. Codex CLI binary not downloaded for x64 during release build
This downloads the binary only for the current platform/arch (the machine running the build). If the release build runs on an arm64 Mac (Apple Silicon), only resources/bin/darwin-arm64/codex is downloaded. The x64 variant is never fetched, so electron-builder's extraResources finds nothing to copy into the x64 build.
The fix should use bun run codex:download:all (line 26) instead, which downloads binaries for all platforms. The same issue applies to bun run claude:download — it should also be bun run claude:download:all.
2. @zed-industries/codex-acp-darwin-x64 not included in ASAR
The @zed-industries/codex-acp wrapper package declares all platform variants as optionalDependencies. When bun install runs on an arm64 machine, bun typically only installs the matching platform optional dependency (codex-acp-darwin-arm64) and skips codex-acp-darwin-x64. Since electron-builder packages node_modules from the build machine, the x64 native binary is absent from the ASAR.
But this only works if the packages are actually installed in node_modules/ in the first place.
Suggested Fix
For the Codex CLI binary: Change the release script to use codex:download:all (and claude:download:all) so all platform binaries are present before electron-builder --mac builds both arm64 and x64 targets.
For the ACP native module: Ensure all platform-specific @zed-industries/codex-acp-* packages are installed at build time. Options include:
Add all platform variants as explicit optionalDependencies in the root package.json (electron-builder will then include them)
Use bun's supportedArchitectures configuration (or the equivalent --arch flag) during bun install to force installation of all platform variants
Run separate bun install steps per target architecture before packaging
The workaround suggestion in the issue (external binary path config) would be addressed separately in codex.ts:237-260 by checking a user-configurable path before falling back to the bundled location.
Activity
21st-connector commentedon Apr 27, 2026
Task completed.
I'll analyze this issue by exploring the codebase to understand how the Codex agent is bundled and identify the root cause and potential fixes.
View full conversation
Powered by 1Code
21st-connector commentedon Apr 27, 2026
Task completed.
I'll analyze this issue by exploring the codebase to understand the Codex agent bundling and packaging setup, then provide a helpful comment.
View full conversation
Powered by 1Code
21st-connector commentedon Apr 27, 2026
Codebase Analysis
This is a legitimate packaging bug affecting the macOS x64 build. Here's what the codebase reveals:
Error 1 — Missing bundled Codex CLI binary
Resolution path:
src/main/lib/trpc/routers/codex.ts:237-260The
resolveBundledCodexCliPath()function (line 237) looks for the binary atprocess.resourcesPath/bin/codexin packaged apps. This binary gets placed there via theextraResourcesconfig inpackage.json:166-172:{ "from": "resources/bin/${platform}-${arch}", "to": "bin" }The binary is downloaded during the release process by
scripts/download-codex-binary.mjs, which has explicitdarwin-x64support (line 32-36) — it downloadscodex-x86_64-apple-darwin.tar.gzintoresources/bin/darwin-x64/codex.Likely cause: The release script (
package.json:27) runsbun run codex:downloadbeforebun run package:mac. Thecodex:downloadcommand (line 25) only downloads for the current platform by default. If the release was built on an arm64 Mac, onlyresources/bin/darwin-arm64/would be populated, and the x64 build would get an emptybin/directory (or none at all). The--allflag exists (codex:download:all, line 26) but is not used in the release script.Error 2 — Missing
@zed-industries/codex-acp-darwin-x64native moduleResolution path:
src/main/lib/trpc/routers/codex.ts:223-235The
resolveCodexAcpBinaryPath()function (line 223) resolves the platform-specific ACP package viarequire.resolve(). The platform package is determined bygetCodexPackageName()(line 188) which correctly mapsdarwin/x64to@zed-industries/codex-acp-darwin-x64.The main
@zed-industries/codex-acppackage (line 76 inpackage.json, version0.9.3) declares these as optional dependencies. TheasarUnpackconfig (package.json:183-184) correctly includes both the wrapper and platform packages:Likely cause:
bun install(or the package manager used during CI) only installs optional native dependencies for the host architecture. When building on an arm64 Mac,@zed-industries/codex-acp-darwin-arm64gets installed but@zed-industries/codex-acp-darwin-x64does not. electron-builder then packages only what's innode_modules/, so the x64 build ships without the x64 ACP binary.Root Cause Summary
Both errors trace back to the same underlying issue: the release is likely built on an arm64 Mac, and cross-architecture dependencies are not installed. The
releasescript inpackage.json:27is:This runs
bun i(installs native deps for host arch only) andcodex:download(downloads CLI binary for host platform only), thenpackage:macbuilds for botharm64andx64targets (package.json:191-193).Suggested Fix Approach
Codex CLI binary: Change the
releasescript to usecodex:download:all(andclaude:download:all) instead of the single-platform variants, soresources/bin/darwin-x64/is populated even when building on arm64.ACP native module: This is trickier. Options include:
npm install --cpu=x64 --os=darwin @zed-industries/codex-acp(or equivalent bun flag) as a pre-build step to force-install cross-arch optional deps.beforeBuildhook ornpmRebuildoption to ensure platform-specific optional deps are installed for each target arch.extraResource(similar to the CLI binary) instead of relying on npm optional deps.Fallback path (addresses the user's suggestion): Adding a UI setting to point to an externally installed
codexbinary would be a useful workaround for edge cases, but should not replace fixing the bundling.Related Issues
Key Files for the Fix
package.json:27codex:download:allandclaude:download:allpackage.json:27bun installstep for optional native depsscripts/download-codex-binary.mjs:26-36darwin-x64— no changes neededsrc/main/lib/trpc/routers/codex.ts:223-260electron.vite.config.ts:22-27@zed-industries/codex-acpadded toexternallist if not already handled byexternalizeDepsPlugin21st-connector commentedon Apr 27, 2026
Issue Analysis
Thanks for the detailed bug report. After analyzing the codebase, here's a breakdown of the root cause and a suggested fix plan.
Root Cause
There are two separate bundling failures for macOS x64, both stemming from the same build pipeline issue:
Error 1: Missing Codex CLI binary (
Resources/bin/codex)The release script (
package.json:27) runs:codex:download(without--all) callsdownload-codex-binary.mjswhich only downloads the binary for the current platform (scripts/download-codex-binary.mjs:371):If the release is built on an arm64 Mac (which is likely), only
resources/bin/darwin-arm64/codexgets downloaded. The electron-builder config then uses${platform}-${arch}substitution to copy per-arch binaries:When building the x64 target, electron-builder looks for
resources/bin/darwin-x64/— which doesn't exist because the download script only fetcheddarwin-arm64. TheextraResourcescopy silently does nothing (no error on missing source), resulting in theContents/Resources/bin/directory being entirely absent from the x64 build.Relevant files:
scripts/download-codex-binary.mjs:370-377— platform detection logicpackage.json:25—codex:downloaduses--version=0.98.0but no--allpackage.json:161-176—extraResourcesconfig with${platform}-${arch}substitutionError 2: Missing
@zed-industries/codex-acp-darwin-x64native moduleThe
@zed-industries/codex-acpwrapper package (v0.9.3) declares all platform variants as optional dependencies (bun.lock:821). Whenbun installruns on an arm64 Mac, bun correctly skipscodex-acp-darwin-x64because itscpufield doesn't match the host.electron-builder's
asarUnpackconfig (package.json:184) correctly includes the globnode_modules/@zed-industries/codex-acp-*/**/*, but since the x64 package was never installed tonode_modules/, there's nothing to unpack.At runtime,
resolveCodexAcpBinaryPath()(src/main/lib/trpc/routers/codex.ts:223-235) callsrequire.resolve("@zed-industries/codex-acp-darwin-x64/bin/codex-acp")which fails because the package doesn't exist in the asar.Relevant files:
src/main/lib/trpc/routers/codex.ts:188-208—getCodexPackageName()selects platform packagesrc/main/lib/trpc/routers/codex.ts:223-235—resolveCodexAcpBinaryPath()resolutionpackage.json:76—@zed-industries/codex-acpdependencySuggested Fix Plan
Fix 1: Download all platform binaries during release
Change the
releasescript inpackage.json:27to usecodex:download:allinstead ofcodex:download:This ensures
resources/bin/darwin-x64/codexexists when electron-builder builds the x64 target. The same issue likely applies toclaude:download— check ifdownload-claude-binary.mjshas the same single-platform default behavior.The
release:devscript (package.json:28) should get the same treatment.Fix 2: Force-install all platform-specific codex-acp packages
For the native ACP module, the build needs all platform variants installed in
node_modules/before packaging. Options:Option A — Add explicit optional dependencies to the project's
package.json:However, bun will still skip packages whose
os/cpudon't match the host. So this alone may not suffice.Option B (Recommended) — Use a pre-package script to explicitly install cross-platform deps:
Add a step in the release script that force-installs the needed platform packages. For example:
Or use npm/yarn for this specific install since they may handle cross-platform optional deps differently.
Option C — Use electron-builder's
beforePackhook to ensure the target platform's native module is present before each arch build. This is the most robust approach for cross-compilation scenarios.Fix 3 (Nice-to-have): Add a fallback for external codex binary
As the reporter suggested, add a setting to allow users to specify an external
codexbinary path. InresolveBundledCodexCliPath()(src/main/lib/trpc/routers/codex.ts:237-260), check for a user-configured path before falling back to the bundled location. This would serve as a workaround for any future bundling issues.Files to Modify
package.json:27-28codex:download:allandclaude:download:allin release scriptspackage.json(new section)optionalDependenciesfor all codex-acp platform variants, or add beforePack hooksrc/main/lib/trpc/routers/codex.ts:237-260electron-builder.ymlorpackage.jsonbuild sectionbeforePackscript for cross-platform native module installationVerification
After fixing, verify by building on an arm64 Mac and checking the x64 output:
21st-connector commentedon Apr 27, 2026
Issue Analysis
Relevant Code Paths
Error 1 — Missing Codex CLI binary is thrown by
resolveBundledCodexCliPath()insrc/main/lib/trpc/routers/codex.ts:237-260. In packaged apps, it expects the binary at{process.resourcesPath}/bin/codex(line 240). This path is populated by electron-builder'sextraResourcesconfig inpackage.json:166-172:{ "from": "resources/bin/${platform}-${arch}", "to": "bin", "filter": ["**/*"] }This copies from
resources/bin/darwin-x64/at build time. The binary is downloaded byscripts/download-codex-binary.mjswhich fetches from theopenai/codexGitHub releases.Error 2 — Missing ACP native module is thrown when
resolveCodexAcpBinaryPath()(codex.ts:223-235) callsrequire.resolve()for@zed-industries/codex-acp-darwin-x64. The platform-specific package is selected bygetCodexPackageName()(codex.ts:188-208).Root Cause Analysis
There are two separate bundling issues:
1. Codex CLI binary not downloaded for x64 during release build
The
releasescript inpackage.json:27runs:This downloads the binary only for the current platform/arch (the machine running the build). If the release build runs on an arm64 Mac (Apple Silicon), only
resources/bin/darwin-arm64/codexis downloaded. The x64 variant is never fetched, so electron-builder'sextraResourcesfinds nothing to copy into the x64 build.The fix should use
bun run codex:download:all(line 26) instead, which downloads binaries for all platforms. The same issue applies tobun run claude:download— it should also bebun run claude:download:all.2.
@zed-industries/codex-acp-darwin-x64not included in ASARThe
@zed-industries/codex-acpwrapper package declares all platform variants asoptionalDependencies. Whenbun installruns on an arm64 machine, bun typically only installs the matching platform optional dependency (codex-acp-darwin-arm64) and skipscodex-acp-darwin-x64. Since electron-builder packagesnode_modulesfrom the build machine, the x64 native binary is absent from the ASAR.The
asarUnpackconfig atpackage.json:183-184correctly declares both patterns:But this only works if the packages are actually installed in
node_modules/in the first place.Suggested Fix
For the Codex CLI binary: Change the
releasescript to usecodex:download:all(andclaude:download:all) so all platform binaries are present beforeelectron-builder --macbuilds both arm64 and x64 targets.For the ACP native module: Ensure all platform-specific
@zed-industries/codex-acp-*packages are installed at build time. Options include:optionalDependenciesin the rootpackage.json(electron-builder will then include them)supportedArchitecturesconfiguration (or the equivalent--archflag) duringbun installto force installation of all platform variantsbun installsteps per target architecture before packagingThe workaround suggestion in the issue (external binary path config) would be addressed separately in
codex.ts:237-260by checking a user-configurable path before falling back to the bundled location.Related Issues
Not a Duplicate
This is a distinct issue. No existing open issues cover the x64 macOS bundling problem for Codex.