Skip to content

dogfood: bun zero-install bun run dev fails, cli can't resolve @webjsdev/server #709

Description

@vivek7405

Problem

A fresh Bun zero-install scaffold cannot start the dev server. Reproduced live with the just-released cli@0.10.26:

bun add -g webjsdev          # webjsdev@0.10.26
bun create webjs my-app      # scaffolds fine, skips install (zero-install)
cd my-app && bun run dev
# $ bun --bun webjs-bun.mjs dev
# error: ENOENT while resolving package '@webjsdev/server' from
#   '/home/vivek/.bun/install/cache/@webjsdev/cli@0.10.26@@@1/bin/webjs.js'
# error: script "dev" exited with code 1

So bun run dev (the most basic command) is broken for a fresh bun zero-install app. bun create worked; the dev server does not.

Root cause (grounded)

Design / approach (candidates, verify empirically)

The bootstrap must resolve the CLI + its @webjsdev/* deps to concrete versions before any in-process onLoad can help.

  1. Pin the bootstrap chain at generation time. The generated webjs-bun.mjs imports the CLI (and the cli reaches the server) via INLINE-versioned specifiers, so bun auto-install fetches the pinned versions. The cli's bare import('@webjsdev/server') is the hard part: have the cli read its own pinned server version and import('@webjsdev/server@<v>'), or rewrite it as a published-artifact transform.
  2. A bunfig.toml preload (see Make webjs db/test/typecheck work under bun zero-install (auto-install, no bun install) #704's verified bun-pin-preload.js) shipped by the scaffold that rewrites the cli's + bootstrap's bare @webjsdev/* imports to pinned inline specifiers. Verify it loads early enough to catch the cli's import.
  3. Make the cli resolve @webjsdev/server via import.meta.resolve against a version it pins internally.

First task: reproduce reliably and determine whether the bare @webjsdev/server auto-install ENOENTs because of (a) the range-ignored-then-latest path, (b) a nested-cache auto-install limitation (a cached package's bare import not triggering project-relative auto-install), or (c) transient fetch flakiness. The fix differs per cause.

Implementation notes (for the implementing agent)

Acceptance criteria

  • A fresh bun create ... && bun run dev serves a 200 with NO bun install.
  • The cli + server resolve to the intended versions (not absolute latest, not ENOENT).
  • Counterfactual test + docs synced.

Relates to #704, #695, #698, #669. Likely should be prioritized above #704 (it breaks the basic dev path).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions