Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/bcode-browser/src/browser-execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ export const make = Effect.fn("BrowserExecute.make")(function* () {
const execute = (args: Parameters, ctx: ExecuteContext) =>
Effect.gen(function* () {
const harnessDir = yield* Effect.promise(() => resolveHarnessDir())
// Pre-flight check on harnessDir: spawn ENOENT on a missing cwd surfaces
// with `path: "uv"` on Bun/Windows, which is indistinguishable from a
// truly-missing uv. Catch it here so the user gets the real cause
// instead of a misleading "uv not on PATH" hint.
if (!(yield* Effect.promise(() => fs.access(harnessDir).then(() => true, () => false)))) {
return yield* Effect.fail(new Error(`harness directory not found at ${harnessDir} — bcode build is broken; please reinstall`))
}
yield* Effect.promise(() => fs.mkdir(ctx.bhTmpDir, { recursive: true }))
const uv = yield* locate
const proc = ChildProcess.make(
Expand Down
10 changes: 9 additions & 1 deletion packages/bcode-browser/src/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ import path from "path"
import { fileURLToPath } from "url"

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

Expand Down
Loading