Skip to content

fix(launcher): honor OPENCODEX_BUN_PATH - #734

Closed
luvs01 wants to merge 4 commits into
lidge-jun:devfrom
luvs01:fix/721-npm-launcher-bun-override
Closed

fix(launcher): honor OPENCODEX_BUN_PATH#734
luvs01 wants to merge 4 commits into
lidge-jun:devfrom
luvs01:fix/721-npm-launcher-bun-override

Conversation

@luvs01

@luvs01 luvs01 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Resolve a valid OPENCODEX_BUN_PATH to an absolute path and prefer it before the npm launcher probes bundled Bun.
  • Warn without exposing the configured path when an override is missing, unreadable, or incomplete, then retain the bundled-runtime fallback.
  • Share the Bun binary size validator through a Node-safe .mjs module used by both the npm launcher and Bun runtime code.
  • Add cross-platform bare-relative/fallback coverage plus a Windows behavioral regression that checks the healthy proxy process's actual executable path and bounded cleanup.

Fixes #721.

Why

Durable service and Codex-shim artifacts already use durableBunRuntime(), which gives a valid explicit override priority. The npm launcher maintained a separate resolver that only considered bundled Bun. Cold ocx gui / direct starts—and the detached direct-start fallback after a service refresh failure—could therefore downgrade the effective proxy runtime to the bundled version.

The launcher now applies the same validation contract as the shared resolver before it touches the bundled dependency. Both launch paths import one Node-safe binary validator, avoiding threshold or error-handling drift.

Behavioral regression

Cross-platform launcher tests invoke node bin/ocx.mjs --version with bare relative overrides and verify both absolute resolution and a path-redacted invalid-override warning. The Windows test launches node bin/ocx.mjs start on isolated homes and free ports, then verifies the actual health PID through CIM:

  • valid copied Bun override → the proxy ExecutablePath is the override
  • sub-1MB override stub → the proxy ExecutablePath is bundled Bun

Cleanup records the spawned launcher PID immediately, retries CIM identity capture, uses the still-live owned child as a bounded tree-cleanup fallback, preserves the primary test failure, probes the owned port for a lingering OpenCodex proxy, and confirms owned processes and fixtures are gone. The runtime and relative-path tests share one isolated launcher environment builder.

Verification

  • node --check bin/ocx.mjs
  • node --check src/lib/bun-binary-validator.mjs
  • Focused suite: 23 passed, 0 failed on each runtime
    • bundled Bun 1.3.14 (0d9b296a)
    • configured Bun 1.4.0-canary.1 (b22e0e6d0)
    • test files: tests/ocx-launcher-source.test.ts, tests/ocx-launcher-runtime.test.ts, tests/bun-runtime.test.ts, tests/install-scripts.test.ts
  • bun x tsc --noEmit: passed on both runtimes
  • bun scripts/privacy-scan.ts: passed on both runtimes
  • git diff --check
  • npm pack --dry-run --ignore-scripts --json: shared validator implementation, declaration, and launcher are included
  • GUI doctor gate: skipped as expected because no gui/ files changed
  • Independent review of the initial review-fix delta: all five initial live threads addressed, no blocking concerns

Full-suite context

A CI-like monolithic Windows run was attempted with the repository's Bun 1.3.14 and a 20-minute command budget. Bun itself hit an internal assertion and crashed after 83.4 seconds while the suite was still in api-storage-policy.test.ts, before reaching the changed launcher tests. This is recorded as a runtime crash, not a passing run or a test assertion failure. A post-crash audit found no worktree-linked Node/Bun survivors and no recent launcher fixtures.

Current dev has a green cross-platform CI baseline. Cross-platform CI for this fork PR still requires repository approval.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (No update needed: this restores the already documented override semantics.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (This reuses an existing explicit runtime override and does not touch auth or credentials.)

Summary by CodeRabbit

  • New Features

    • Added explicit Bun runtime override via OPENCODEX_BUN_PATH, including support for relative paths.
  • Bug Fixes

    • Bun override paths are validated as real binaries before use; invalid values now emit a clearer message and safely fall back to the bundled runtime.
    • Improved Windows runtime selection consistency.
  • Tests

    • Expanded coverage for override validation, relative override handling, fallback behavior, and Windows runtime effectiveness with health/identity verification and resilient cleanup.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The npm launcher now honors valid OPENCODEX_BUN_PATH values, rejects invalid or undersized overrides, and falls back to bundled Bun resolution. A shared validator and Windows runtime tests verify effective proxy selection and fallback behavior.

Changes

Bun override launcher

Layer / File(s) Summary
Shared validator and override-aware resolution
src/lib/bun-binary-validator.*, src/lib/bun-runtime.ts, bin/ocx.mjs, tests/bun-runtime.test.ts
Adds centralized Bun binary validation, prioritizes valid OPENCODEX_BUN_PATH values, validates bundled candidates, resolves relative overrides from the launcher working directory, and isolates environment-dependent tests.
Windows effective-runtime validation
tests/ocx-launcher-runtime.test.ts
Launches the proxy, checks health and Windows process identity, verifies valid and invalid override behavior, and performs bounded cleanup.
Resolver ordering and validator-sharing assertions
tests/ocx-launcher-source.test.ts
Checks override-before-bundled resolution, safe invalid-path handling, and shared validator implementation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RuntimeTest
  participant OcxLauncher
  participant BunValidator
  participant ProxyProcess
  RuntimeTest->>OcxLauncher: Spawn with OPENCODEX_BUN_PATH
  OcxLauncher->>BunValidator: Validate override
  BunValidator-->>OcxLauncher: Select override or bundled Bun
  OcxLauncher->>ProxyProcess: Start proxy with selected runtime
  ProxyProcess-->>RuntimeTest: Report health and process identity
Loading

Suggested labels: bug

Suggested reviewers: ingwannu, wibias, lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the main launcher change to honor OPENCODEX_BUN_PATH.
Linked Issues check ✅ Passed The launcher now prefers a validated OPENCODEX_BUN_PATH and falls back safely, matching issue #721's direct-start behavior.
Out of Scope Changes check ✅ Passed The added validator, Bun runtime updates, and regression tests all support the override fix and do not introduce unrelated behavior.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Jul 30, 2026
@luvs01
luvs01 force-pushed the fix/721-npm-launcher-bun-override branch from 3837865 to fa455f7 Compare July 30, 2026 05:47
@luvs01
luvs01 marked this pull request as ready for review July 30, 2026 07:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa455f7798

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/ocx.mjs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bin/ocx.mjs`:
- Around line 328-333: Update resolveBun so a non-empty OPENCODEX_BUN_PATH
override that fails isRealBunBinary emits a diagnostic identifying the rejected
path and reason before falling back to the bundled runtime; preserve the
existing behavior for valid overrides and unset values.
- Around line 295-313: Unify the Bun binary validation used by findBunBinary and
the corresponding validator in bun-runtime.ts by extracting the shared
existsSync/statSync size-check logic into a reusable helper, or add an explicit
cross-reference if sharing across these launch paths is impractical. Preserve
REAL_BUN_MIN_BYTES and the current false-on-error behavior, and update both
callers to use the single source of truth.

In `@tests/ocx-launcher-runtime.test.ts`:
- Around line 160-189: Ensure the spawned launcher is cleaned up even when
windowsProcessIdentity(launcher.pid) returns null or throws before ownedLauncher
is assigned. Add a fallback cleanup path keyed by the trusted launcher.pid,
using the existing killProxy process-tree cleanup mechanism, and preserve
ownedLauncher/ownedProxy cleanup for successfully identified processes.
- Around line 190-214: Update the cleanup logic in the test’s finally block so
cleanupErrors never throws over an exception from the main try block. Preserve
the cleanup attempts and ensure cleanup failures are reported without replacing
the primary test failure, using the surrounding test error-handling flow or
deferred reporting mechanism.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6726e791-aadd-4691-b359-e77acc7b5df8

📥 Commits

Reviewing files that changed from the base of the PR and between 0666b41 and fa455f7.

📒 Files selected for processing (3)
  • bin/ocx.mjs
  • tests/ocx-launcher-runtime.test.ts
  • tests/ocx-launcher-source.test.ts

Comment thread bin/ocx.mjs
Comment thread bin/ocx.mjs
Comment thread tests/ocx-launcher-runtime.test.ts Outdated
Comment thread tests/ocx-launcher-runtime.test.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/ocx-launcher-runtime.test.ts (1)

178-315: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

isolatedLauncherEnv() duplicates the env/dir setup already inlined in effectiveRuntime().

effectiveRuntime() (Lines 180-182, 192-194, 199-207) and isolatedLauncherEnv() (Lines 299-315) build the identical opencodexHome/codexHome/grokHome directories and the identical HOME/USERPROFILE/OPENCODEX_HOME/CODEX_HOME/GROK_HOME/OPENCODEX_BUN_PATH env shape, in the same file, in the same diff. Since isolatedLauncherEnv is defined right after effectiveRuntime but never called from it, this reads like an extraction that should have replaced the inline block.

♻️ Proposed fix: have `effectiveRuntime` reuse `isolatedLauncherEnv`
 async function effectiveRuntime(override: string): Promise<string> {
   const root = mkdtempSync(join(tmpdir(), "ocx-launcher-runtime-"));
-  const opencodexHome = join(root, "opencodex");
-  const codexHome = join(root, "codex");
-  const grokHome = join(root, "grok");
   let port: number | null = null;
   let launcher: ChildProcess | null = null;
   let launcherPid: number | null = null;
   let ownedLauncher: WindowsProcessIdentity | null = null;
   let ownedProxy: WindowsProcessIdentity | null = null;
   let runtimePath: string | undefined;
   let hasPrimaryError = false;
   let primaryError: unknown;
   try {
-    mkdirSync(opencodexHome, { recursive: true });
-    mkdirSync(codexHome, { recursive: true });
-    mkdirSync(grokHome, { recursive: true });
     port = await freePort();
     launcher = spawn("node", [BIN_OCX, "start", "--port", String(port)], {
       stdio: "ignore",
       windowsHide: true,
-      env: {
-        ...process.env,
-        HOME: root,
-        USERPROFILE: root,
-        OPENCODEX_HOME: opencodexHome,
-        CODEX_HOME: codexHome,
-        GROK_HOME: grokHome,
-        OPENCODEX_BUN_PATH: override,
-      },
+      env: isolatedLauncherEnv(root, override),
     });

(Move the isolatedLauncherEnv function definition above effectiveRuntime or hoist it, since function declarations are hoisted in TS/JS this is safe either way.)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/ocx-launcher-runtime.test.ts` around lines 178 - 315, Update
effectiveRuntime to reuse isolatedLauncherEnv for creating the home directories
and constructing the launcher environment, passing the temporary root and
override values instead of maintaining the duplicated inline setup. Preserve the
existing launcher behavior and remove only the redundant directory and
environment construction.
♻️ Duplicate comments (1)
bin/ocx.mjs (1)

293-305: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Extract the Bun-binary validator into one shared plain-JS module instead of documenting a manual sync. bin/ocx.mjs's isRealBunBinary()/REAL_BUN_MIN_BYTES is a byte-for-byte copy of src/lib/bun-runtime.ts's, and the only guard against drift is a test that checks a comment string exists — neither actually verifies the two thresholds/logic stay identical.

  • bin/ocx.mjs#L293-L305: extract isRealBunBinary and REAL_BUN_MIN_BYTES into a new plain .mjs file (e.g. src/lib/bun-binary-validator.mjs) that uses only node:fs (existsSync/statSync) — no Bun-specific APIs — so it can be imported unmodified from this Node-executed launcher before any Bun binary is resolved; replace the local copy with an import from that module.
  • tests/ocx-launcher-source.test.ts#L48-L50: once both files import the shared module, replace (or supplement) the comment-text assertion with a real parity check — e.g. import the shared module directly and assert bin/ocx.mjs/src/lib/bun-runtime.ts both reference it, or assert the exported REAL_BUN_MIN_BYTES value matches between call sites — so an actual threshold/logic change in one place is caught rather than just a missing comment.
♻️ Proposed shared module sketch
// src/lib/bun-binary-validator.mjs
import { existsSync, statSync } from "node:fs";

export const REAL_BUN_MIN_BYTES = 1_000_000;

export function isRealBunBinary(path) {
  try {
    return existsSync(path) && statSync(path).size >= REAL_BUN_MIN_BYTES;
  } catch {
    return false;
  }
}
-function isRealBunBinary(path) {
-  try {
-    return existsSync(path) && statSync(path).size >= REAL_BUN_MIN_BYTES;
-  } catch {
-    return false;
-  }
-}
+import { isRealBunBinary } from "../src/lib/bun-binary-validator.mjs";
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bin/ocx.mjs` around lines 293 - 305, Extract REAL_BUN_MIN_BYTES and
isRealBunBinary into a shared Node-safe plain-JS module, update bin/ocx.mjs and
src/lib/bun-runtime.ts to import it, and remove the duplicated implementations.
In tests/ocx-launcher-source.test.ts lines 48-50, replace the comment-only
assertion with a parity check that verifies both call sites use the shared
validator or exported threshold, catching future drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@tests/ocx-launcher-runtime.test.ts`:
- Around line 178-315: Update effectiveRuntime to reuse isolatedLauncherEnv for
creating the home directories and constructing the launcher environment, passing
the temporary root and override values instead of maintaining the duplicated
inline setup. Preserve the existing launcher behavior and remove only the
redundant directory and environment construction.

---

Duplicate comments:
In `@bin/ocx.mjs`:
- Around line 293-305: Extract REAL_BUN_MIN_BYTES and isRealBunBinary into a
shared Node-safe plain-JS module, update bin/ocx.mjs and src/lib/bun-runtime.ts
to import it, and remove the duplicated implementations. In
tests/ocx-launcher-source.test.ts lines 48-50, replace the comment-only
assertion with a parity check that verifies both call sites use the shared
validator or exported threshold, catching future drift.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7f2cbc11-468b-4683-a4a6-38077860c5be

📥 Commits

Reviewing files that changed from the base of the PR and between fa455f7 and 68e6d5c.

📒 Files selected for processing (4)
  • bin/ocx.mjs
  • tests/bun-runtime.test.ts
  • tests/ocx-launcher-runtime.test.ts
  • tests/ocx-launcher-source.test.ts

luvs01 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the follow-up review in 191e7e2. The launcher and Bun runtime now share one Node-safe validator (with a packaged .d.mts declaration), and the Windows runtime test reuses the isolated environment helper. The 23 focused tests, typecheck, and privacy scan pass on both Bun 1.3.14 and the configured Bun 1.4.0-canary.1 (b22e0e6d0); Node syntax, diff, and package-content checks also pass.

@luvs01
luvs01 force-pushed the fix/721-npm-launcher-bun-override branch from 191e7e2 to 72db422 Compare July 30, 2026 12:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bin/ocx.mjs`:
- Around line 317-327: The overrideBunPath() logic in src/lib/bun-runtime.ts
must normalize OPENCODEX_BUN_PATH before validation. Trim the environment value,
resolve it against the current working directory, and pass the resolved path to
isRealBunBinary(), matching bin/ocx.mjs behavior; add a regression test covering
a relative override from a different launcher cwd.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 56e6cd3a-9e1d-4cfc-8f02-3f400653d2d7

📥 Commits

Reviewing files that changed from the base of the PR and between 191e7e2 and 72db422.

📒 Files selected for processing (7)
  • bin/ocx.mjs
  • src/lib/bun-binary-validator.d.mts
  • src/lib/bun-binary-validator.mjs
  • src/lib/bun-runtime.ts
  • tests/bun-runtime.test.ts
  • tests/ocx-launcher-runtime.test.ts
  • tests/ocx-launcher-source.test.ts

Comment thread bin/ocx.mjs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/bun-runtime.ts`:
- Around line 51-52: Update isRealBunBinary, used by the override selection in
bun-runtime.ts, to reject oversized files unless they are regular files that are
readable, executable where required by the platform, and valid Bun binaries.
Ensure durableBunRuntime() falls back to the bundled runtime for invalid
overrides, and add a regression fixture covering large text, non-Bun executable,
and unreadable files.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5f151c25-4ee1-4f92-9b1d-153272107629

📥 Commits

Reviewing files that changed from the base of the PR and between 72db422 and 643220f.

📒 Files selected for processing (2)
  • src/lib/bun-runtime.ts
  • tests/bun-runtime.test.ts

Comment thread src/lib/bun-runtime.ts
Comment on lines +51 to +52
const resolved = resolve(value);
return isRealBunBinary(resolved) ? resolved : null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Reject large non-Bun or non-executable overrides before selecting them.

The shared validator in src/lib/bun-binary-validator.mjs only checks existence and file size. A large text file, non-Bun executable, or unreadable file can therefore pass Line 52; durableBunRuntime() will select it as the override and skip the bundled fallback. Add regular-file plus platform-appropriate executable/Bun validation, and cover this with a regression fixture.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/bun-runtime.ts` around lines 51 - 52, Update isRealBunBinary, used by
the override selection in bun-runtime.ts, to reject oversized files unless they
are regular files that are readable, executable where required by the platform,
and valid Bun binaries. Ensure durableBunRuntime() falls back to the bundled
runtime for invalid overrides, and add a regression fixture covering large text,
non-Bun executable, and unreadable files.

@lidge-jun

Copy link
Copy Markdown
Owner

LAND-AFTER — correcting an earlier triage call.

This PR was previously slated as NEEDS-CHANGES on the grounds that it conflicted with dev. That is no longer true, and the correction belongs on the record: your force-push at 12:02 UTC put head 72db422a9 directly on top of d0141e7c8, and git merge-tree --write-tree against the current dev head comes back clean. There is nothing for you to resolve. Apologies for the stale label.

On the substance, this resolves #721 the way it should be resolved. bin/ocx.mjs:316-345 reads and validates OPENCODEX_BUN_PATH before bundled-Bun discovery, so an explicit override actually wins instead of being silently outranked. Extracting the size validation into src/lib/bun-binary-validator.mjs is the right move given the launcher runs under Node before Bun exists — a shared .mjs module is one of the few things both halves can import. The launcher tests cover a valid override, fallback on an invalid one, and path redaction, which is the set that matters here.

What happens next: nothing required from you. This lands after the release blockers, alongside the other queued PRs.


CI context (shared across the current review round). dev is now at 62e937614. The baseline breakage that made every required check red is fixed: run 30545575865 has macos-latest, ubuntu-latest, and all three npm-global jobs green. The one remaining red is windows-latest, and it is not a test failure — it is a Bun 1.3.14 runtime panic (heap.zig:deleteMin reached through spawnSync with a timeout, triggered by our Windows ACL hardening path). That is a runtime defect being tracked separately, so please do not treat a red windows-latest as a signal about your change. Rebase onto current dev before your next push so your checks run against the repaired baseline.

@lidge-jun

Copy link
Copy Markdown
Owner

Found a test failure while trial-merging this against current dev. It is a test portability bug rather than a defect in your launcher change, but it will turn macos-latest red so it has to be fixed before this can land.

(fail) bundledBunPath / durableBunPath > resolves a relative override against the launcher cwd
Expected: "/var/folders/.../ocx-bun-runtime-XXXX/launcher-cwd/relative-bun.exe"
Received: "/private/var/folders/.../ocx-bun-runtime-XXXX/launcher-cwd/relative-bun.exe"
   at tests/bun-runtime.test.ts:74

/var is a symlink to /private/var on macOS. mkdtemp hands back the /var form, but once the test calls process.chdir(launcherCwd), anything resolved against the working directory comes back as the realpath under /private/var. So the expected value and the resolved value describe the same file and compare unequal.

This reproduces with the PR alone on top of dev — 7 pass, 1 fail — so it is not an interaction with anything else in the queue.

The fix is to compare realpaths rather than the raw temp path. Either run the temp root through realpathSync when you build tmp, or wrap the expected value at the assertion:

const real = realpathSync(join(launcherCwd, "relative-bun.exe"));

Resolving at the tmp root is probably cleaner since the other cases in this file will hit the same thing the moment they touch cwd.

Everything else looks good — the rest of the file passes, the merge is clean against current dev, and the OPENCODEX_BUN_PATH handling itself is correct. This is the last thing standing between the PR and a merge.

lidge-jun added a commit that referenced this pull request Jul 31, 2026
PR #734's launcher change is correct, but its test built the expected path from
mkdtemp and then asserted against a value resolved through process.cwd(). On
macOS /var is a symlink to /private/var, so the two forms of the same file
compared unequal and the case failed on macos-latest only.

Fixed at the source rather than at the assertion: realpathSync wraps the
mkdtemp root, so every case in the file resolves consistently instead of just
the one that happened to break. 7 pass / 1 fail before, 8 pass / 0 fail after.
@lidge-jun

Copy link
Copy Markdown
Owner

Closing — this is already merged. 9b5c864ff merge: PR #734 carries the launcher fix (src/lib/bun-runtime.ts:48-60, bin/ocx.mjs:316-346); the PR just stayed open afterwards.

The macOS test failure that held it up is also fixed: f81e98aca test(bun-runtime): resolve the temp root so macOS paths compare equal realpaths the temp root before the chdir comparison, because /var is a symlink to /private/var (tests/bun-runtime.test.ts:7-9). bun test tests/bun-runtime.test.ts is 8/8 on macOS now.

#721 is closed with that evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants