Skip to content

Commit 95bb954

Browse files
authored
Merge pull request #25 from browser-use/fix/windows-bunfs-dirname-detection
fix(bcode-browser): detect compiled mode on Windows; pre-flight harnessDir
2 parents 46afdba + 3b9b342 commit 95bb954

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

packages/bcode-browser/src/browser-execute.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ export const make = Effect.fn("BrowserExecute.make")(function* () {
9292
const execute = (args: Parameters, ctx: ExecuteContext) =>
9393
Effect.gen(function* () {
9494
const harnessDir = yield* Effect.promise(() => resolveHarnessDir())
95+
// Pre-flight check on harnessDir: spawn ENOENT on a missing cwd surfaces
96+
// with `path: "uv"` on Bun/Windows, which is indistinguishable from a
97+
// truly-missing uv. Catch it here so the user gets the real cause
98+
// instead of a misleading "uv not on PATH" hint.
99+
if (!(yield* Effect.promise(() => fs.access(harnessDir).then(() => true, () => false)))) {
100+
return yield* Effect.fail(new Error(`harness directory not found at ${harnessDir} — bcode build is broken; please reinstall`))
101+
}
95102
yield* Effect.promise(() => fs.mkdir(ctx.bhTmpDir, { recursive: true }))
96103
const uv = yield* locate
97104
const proc = ChildProcess.make(

packages/bcode-browser/src/harness.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ import path from "path"
3737
import { fileURLToPath } from "url"
3838

3939
const __dirname = path.dirname(fileURLToPath(import.meta.url))
40-
const isCompiled = __dirname.startsWith("/$bunfs/") || __dirname.startsWith("B:/~BUN/")
40+
// Bun's bunfs root is `/$bunfs/` on POSIX and `B:\~BUN\` on Windows (native
41+
// separators). Normalize before comparing so the compiled-mode check works on
42+
// both platforms — without this, the Windows compiled binary falls through to
43+
// DEV_HARNESS_DIR (which doesn't exist on the user's machine) and every
44+
// subsequent spawn fails with a misleading uv-missing error.
45+
const isCompiled = (() => {
46+
const d = __dirname.replaceAll("\\", "/")
47+
return d.startsWith("/$bunfs/") || d.startsWith("B:/~BUN/")
48+
})()
4149
const DEV_HARNESS_DIR = path.resolve(__dirname, "..", "harness")
4250
const cachedHarnessDir = path.join(os.homedir(), ".cache", "bcode", "harness")
4351

0 commit comments

Comments
 (0)