fix(bcode-browser): detect compiled mode on Windows; pre-flight harnessDir#25
Merged
Alezander9 merged 1 commit intomainfrom Apr 30, 2026
Merged
Conversation
…ssDir
The bunfs root is /$bunfs/ on POSIX but B:\~BUN\ on Windows (native
separators), so `__dirname.startsWith("B:/~BUN/")` was always false in
Windows compiled binaries. Result: isCompiled=false, resolveHarnessDir
returned the dev path which doesn't exist on installs, the harness was
never extracted, and every spawn failed with cwd=ENOENT. Bun's spawn
attributes that ENOENT to path="uv", so isUvMissing matched and the
agent reported a misleading 'uv not on PATH' error -- even though uv
was installed and on PATH.
Two fixes:
1. harness.ts: normalize __dirname to forward slashes before the bunfs
prefix check, so the same comparison works on Windows and POSIX.
2. browser-execute.ts: fs.access(harnessDir) before spawn. If the
directory is missing, fail with a clear message instead of falling
into the spawn-ENOENT path that gets misclassified as uv-missing.
Reproduced on Windows 11 with v0.0.5 binary (and a locally-built one).
Pre-fix: ~/.cache/bcode/harness was never created; agent reported uv
missing despite uv being installed and on PATH.
Post-fix: harness extracts on first run, agent attaches to Chrome,
end-to-end browser_execute works.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two-fix combo for a Windows-only false positive where the compiled
bcodebinary reportsuv is not installed or not on PATHeven when uv is present.Repro
bcodev0.0.5 on Windows 11 (uv already installed at~/.local/bin/uv.exe, on PATH).bcode run "<anything that triggers browser_execute>".UV_MISSING_HINTand stops.~/.cache/bcode/harnessis never created, even though the binary embeds 120+ harness files.Why
packages/bcode-browser/src/harness.ts:40:In a Bun-compiled binary on Windows,
__dirnameisB:\~BUN\root(native backslashes), notB:/~BUN/. SoisCompiled === false,resolveHarnessDir()returnsDEV_HARNESS_DIR = path.resolve(__dirname, "..", "harness")which doesn't exist on disk, and the harness is never extracted.browser-execute.tsthen callsChildProcess.make(uv, [...], { cwd: harnessDir }). Bun's spawn on Windows, whencwddoesn't exist, throwscode: "ENOENT"withpath: "uv"? it blames the command, not the cwd.isUvMissing()walks the cause chain looking forcode === "ENOENT", matches, and returns true ? user sees the misleading uv hint.Fix
harness.ts: normalize__dirnameto forward slashes before the bunfs prefix check, so the same comparison works on Windows and POSIX.browser-execute.ts: pre-flightfs.access(harnessDir)before spawn. If missing, fail with a clear message instead of falling into the spawn-ENOENT path that gets misclassified as uv-missing. This is belt-and-braces in case future regressions break extraction again.Verification
__dirname=B:\~BUN\root(backslashes), confirmingisCompiled=false.~/.cache/bcode/harnessis created on first call, contains 1457 files.bcode run "connect to my open chrome..."attaches to Chrome and navigates successfully (no false uv error).bun run dev run "...") still works.bun typecheckclean.Modification zone
Level 1 (Green) ?
packages/bcode-browser/only. No vendored harness changes, no opencode changes, noUPSTREAM.mdupdate needed.