Skip to content

Resolve the plugin root from sim-host.mjs, not by counting ../ from the bundle - #3

Open
dhiyaancnirmal wants to merge 1 commit into
vburojevic:mainfrom
dhiyaancnirmal:fix/plugin-root-from-bundle
Open

Resolve the plugin root from sim-host.mjs, not by counting ../ from the bundle#3
dhiyaancnirmal wants to merge 1 commit into
vburojevic:mainfrom
dhiyaancnirmal:fix/plugin-root-from-bundle

Conversation

@dhiyaancnirmal

Copy link
Copy Markdown

Problem

On a git install (bb plugin install xcode from the marketplace), bb xcode sim doctor reports:

STOP  Capture addon
      serve-sim's native capture addon did not load. …
STOP  serve-sim
      serve-sim is not installed. …

even though node_modules/serve-sim and its dist/native/serve-sim-native.node are present. Live is blocked by the STOP.

Cause

src/sim/wire.ts builds the preflight deps with new URL("../../", import.meta.url). Two above src/sim/wire.ts is the plugin root, but two above the bundled dist/server.js is the directory containing the install — for a git install, ~/.bb/plugins/cache/git/github.com/<owner>/bb-plugin-xcode/, which has no node_modules. require.resolve("serve-sim/middleware") from there fails, and the doctor concludes serve-sim is missing.

Reproduced on bb 0.41.0 / macOS 26.5 / Xcode 27 beta with v0.2.2 from the marketplace, and the same line is on main. A node_modules symlink one level up makes the doctor pass, which confirms the diagnosis.

Fix

resolveSimHostPath already searches both layouts for sim-host.mjs, which sits at the plugin root, so the root is its dirname. Hoisted that lookup above the preflight wiring and reused it. No behaviour change when evaluated from source.

npm run check passes.

…he bundle

defaultDeps() was handed new URL("../../", import.meta.url), which is the
plugin root when evaluated from src/sim/wire.ts but, from the bundled
dist/server.js, is the directory *containing* the install. For a git install
that is ~/.bb/plugins/cache/git/github.com/<owner>/bb-plugin-xcode/, which has
no node_modules, so require.resolve("serve-sim/middleware") fails and
`bb xcode sim doctor` reports serve-sim as not installed on a machine where
it is — with a STOP that blocks Live.

resolveSimHostPath already searches both layouts for sim-host.mjs, which sits
at the plugin root, so the root is simply its directory. Hoisted that lookup
above the preflight wiring and reused it.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T00:04:45.682801Z 77246d2 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant