Skip to content

fix: honor --prefix when resolving workspace dir (release/10)#11550

Merged
zkochan merged 1 commit into
release/10from
fix/11535-v10
May 12, 2026
Merged

fix: honor --prefix when resolving workspace dir (release/10)#11550
zkochan merged 1 commit into
release/10from
fix/11535-v10

Conversation

@zkochan

@zkochan zkochan commented May 8, 2026

Copy link
Copy Markdown
Member

Backport of #11549 to release/10.

Summary

Fixes #11535 on the v10 line. The CLI's --prefix → dir rename was applied after getWorkspaceDir(options) had already run, so workspace detection fell back to process.cwd() instead of the prefix dir. Running pnpm from outside the project (e.g. pnpm --prefix=child install from the parent dir) silently skipped the workspace manifest at child/pnpm-workspace.yaml, so any settings declared there (e.g. allowBuilds, overrides) were not loaded into config.

The destructive overwrite reported in #11535 only manifests on v11 (where pnpm install auto-populates allowBuilds placeholders into the workspace manifest), but the underlying CLI ordering bug is identical on v10 and still causes silently-incorrect settings resolution for any write-back path. Fixing it here keeps behavior consistent.

The fix moves the rename loop ahead of getWorkspaceDir, makes the canonical option win when both --prefix and --dir are passed (so the alias never silently overwrites an explicit value), and threads renamedOptions into getWorkspaceDir so the --help/--version short-circuit paths also resolve --prefix correctly.

Test plan

  • Added 4 regression tests in cli/parse-cli-args/test/index.ts
  • All 43 tests in @pnpm/parse-cli-args pass
  • Lint passes

Written by an agent (Claude Code, claude-opus-4-7).

The `--prefix` option (renamed to `dir`) was applied to options after
`getWorkspaceDir` had already run, so workspace detection fell back to
`process.cwd()` and missed the manifest at the prefix dir. As a result,
running pnpm from outside the project (e.g. `pnpm --prefix=child install`
from the parent dir) silently skipped settings declared in
`child/pnpm-workspace.yaml`.

Backport of #11549 to release/10. Closes #11535.
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d1193466-b798-4943-abaa-1d8d4426cdad

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/11535-v10

Comment @coderabbitai help to get the list of available commands and usage tips.

@zkochan zkochan merged commit 80306c4 into release/10 May 12, 2026
13 of 14 checks passed
@zkochan zkochan deleted the fix/11535-v10 branch May 12, 2026 08:16
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