Fix bin/setup failing on pnpm workspace member directories#2477
Fix bin/setup failing on pnpm workspace member directories#2477
Conversation
Workspace members like spec/dummy don't have their own pnpm-lock.yaml — their dependencies are managed by the root pnpm install. Skip running pnpm install --frozen-lockfile in directories without a lockfile. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WalkthroughThe setup script now conditionally runs Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryFixed
The change is minimal, well-targeted, and aligns with pnpm workspace conventions where member packages don't maintain their own lockfiles. Confidence Score: 5/5
Important Files Changed
Last reviewed commit: e3d38d3 |
ReviewThe fix is correct and minimal. Workspace members ( A few observations: 1. Implicit assumption about what a missing lockfile means The heuristic is: "if A more explicit alternative would be checking for 2.
3. Ordering in The script always calls Summary: Functionally correct. The lockfile heuristic works for the current directory set. Points 1 and 2 are worth noting for robustness as the repo evolves, but neither is a blocker. |
| fi | ||
| print_success "JavaScript dependencies installed" | ||
| elif [ -f "package.json" ]; then | ||
| print_success "JavaScript dependencies managed by workspace root" |
There was a problem hiding this comment.
Minor: print_success (green checkmark) typically signals a completed action. For a skipped step it could give a false sense that installation was verified. Consider using a plain echo with an informational prefix instead:
| print_success "JavaScript dependencies managed by workspace root" | |
| echo " JavaScript dependencies managed by workspace root (skipping local install)" |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@bin/setup`:
- Around line 160-168: The current branch that detects workspace-managed
packages (elif [ -f "package.json" ]) silently prints success when
pnpm-lock.yaml is missing; change that to make skips visible and optionally
tighten detection: in the elif block replace print_success with print_warning
(so missing lockfile is surfaced), and if you want a stricter fix add an
explicit allowlist (e.g. WORKSPACE_ONLY_DIRS or WORKSPACE_MANAGED_DIRS) and
check membership before skipping the install instead of relying solely on
pnpm-lock.yaml; keep the pnpm install path (pnpm install --frozen-lockfile and
print_error on failure) unchanged.
| if [ -f "package.json" ] && [ -f "pnpm-lock.yaml" ]; then | ||
| echo " Installing JavaScript dependencies..." | ||
| if ! pnpm install --frozen-lockfile; then | ||
| print_error "Failed to install JavaScript dependencies in $name" | ||
| exit 1 | ||
| fi | ||
| print_success "JavaScript dependencies installed" | ||
| elif [ -f "package.json" ]; then | ||
| print_success "JavaScript dependencies managed by workspace root" |
There was a problem hiding this comment.
Silent skip if a lockfile is accidentally missing in a non-workspace directory.
The heuristic equates "no pnpm-lock.yaml" with "workspace member", which is valid today. However, if a directory that should own a lockfile (e.g., root or react_on_rails_pro) accidentally loses it, the script will silently print "JavaScript dependencies managed by workspace root" and proceed without installing — potentially causing confusing downstream failures instead of a clear error here.
If the set of workspace-managed directories is stable and well-known, consider tightening the guard to an explicit allowlist rather than pure lockfile detection:
💡 Proposed alternative: explicit skip list
- # Skip pnpm install for workspace members (no lockfile) — they're covered by root install
- if [ -f "package.json" ] && [ -f "pnpm-lock.yaml" ]; then
+ # Workspace members (no pnpm-lock.yaml) are covered by the root install.
+ # If pnpm-lock.yaml is missing but this is NOT a known workspace member, warn loudly.
+ if [ -f "package.json" ] && [ -f "pnpm-lock.yaml" ]; then
echo " Installing JavaScript dependencies..."
if ! pnpm install --frozen-lockfile; then
print_error "Failed to install JavaScript dependencies in $name"
exit 1
fi
print_success "JavaScript dependencies installed"
elif [ -f "package.json" ]; then
- print_success "JavaScript dependencies managed by workspace root"
+ print_warning "No pnpm-lock.yaml found in $name — skipping pnpm install (assuming workspace member)"
fiAt minimum, changing print_success to print_warning here makes the skip visible enough to catch the accidental case during local setup.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@bin/setup` around lines 160 - 168, The current branch that detects
workspace-managed packages (elif [ -f "package.json" ]) silently prints success
when pnpm-lock.yaml is missing; change that to make skips visible and optionally
tighten detection: in the elif block replace print_success with print_warning
(so missing lockfile is surfaced), and if you want a stricter fix add an
explicit allowlist (e.g. WORKSPACE_ONLY_DIRS or WORKSPACE_MANAGED_DIRS) and
check membership before skipping the install instead of relying solely on
pnpm-lock.yaml; keep the pnpm install path (pnpm install --frozen-lockfile and
print_error on failure) unchanged.
Summary
bin/setupwas failing on workspace member directories (e.g.,spec/dummy) because it ranpnpm install --frozen-lockfilein directories without apnpm-lock.yamlpnpm install, so they don't need their own install steppnpm install, and prints a message that dependencies are managed by the workspace rootTest plan
bin/setup --skip-prolocally — completes successfully🤖 Generated with Claude Code
Note
Low Risk
Small, localized change to setup scripting that only relaxes a directory-level precondition for running
pnpm install.Overview
Fixes
bin/setupfailures in pnpm workspace member directories by only runningpnpm install --frozen-lockfilewhen a localpnpm-lock.yamlexists.If a directory has a
package.jsonbut no lockfile (typical for workspace members like dummy apps), the script now skips the install step and reports that JS dependencies are managed by the workspace root.Written by Cursor Bugbot for commit e3d38d3. Configure here.
Summary by CodeRabbit