Skip to content

chore: install deps in a fresh bb worktree (MX-243) - #18

Merged
MGrin merged 1 commit into
mainfrom
mx243-env-setup-hook
Aug 21, 2026
Merged

chore: install deps in a fresh bb worktree (MX-243)#18
MGrin merged 1 commit into
mainfrom
mx243-env-setup-hook

Conversation

@MGrin

@MGrin MGrin commented Aug 21, 2026

Copy link
Copy Markdown
Owner

MGrin/bb-plugin-accounts and MGrin/bb-plugin-flare-operator are bb projects that track a package.json and had no committed .bb-env-setup.sh, so every worktree bb created for them arrived with no node_modules — and bb continues silently when the hook is absent (bb guide environments), so nothing said so.

The failure that follows is silent too: the agent standing in that empty worktree sources a dependency tree from another checkout on this disk. Measured in MX-239 over 15 candidate donors, 12 held the wrong resolved version, and that green leaves no diff, no install log and no lockfile change.

What this adds

One tracked .bb-env-setup.sh at the repo root — tracked is load-bearing, an untracked one is absent in the worktree and never runs — plus .npmcache/ in .gitignore.

--cache "$PWD/.npmcache" is deliberate and the comment says why: from inside the agent Bash sandbox a plain npm install fails claiming ~/.npm "contains root-owned files" and prescribes sudo chown. That is false (0 of ~114500 files there are root-owned) — it is a sandbox read-denial wearing an ownership error, with a remedy an agent cannot run.

The script is never fatal: bb deletes the new worktree if the hook exits non-zero.

Verified

Ran env bash .bb-env-setup.sh — the way bb runs it — in a fresh worktree with no node_modules, then the repo's own suite against the tree it produced. shellcheck -x clean.

🤖 Generated with Claude Code

A bb-managed worktree checks out tracked files only, so this repo's worktrees
arrived with no node_modules and bb said nothing — an absent .bb-env-setup.sh
means provisioning continues silently. The agent standing in that worktree then
copies a dependency tree from another checkout on this disk, which leaves no
diff, no install log and no lockfile change (MX-239: 12 of 15 candidate donors
held the wrong resolved version).

The --cache inside the workspace is not decorative: from inside the agent Bash
sandbox a plain `npm install` fails claiming ~/.npm "contains root-owned files"
and prescribes sudo, which is false and unrunnable by an agent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@MGrin
MGrin merged commit 8475df3 into main Aug 21, 2026
1 check passed
@MGrin
MGrin deleted the mx243-env-setup-hook branch August 21, 2026 03:11
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