fix: honor --prefix when resolving workspace dir (release/10)#11550
Merged
Conversation
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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #11549 to
release/10.Summary
Fixes #11535 on the v10 line. The CLI's
--prefix → dirrename was applied aftergetWorkspaceDir(options)had already run, so workspace detection fell back toprocess.cwd()instead of the prefix dir. Running pnpm from outside the project (e.g.pnpm --prefix=child installfrom the parent dir) silently skipped the workspace manifest atchild/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 installauto-populatesallowBuildsplaceholders 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--prefixand--dirare passed (so the alias never silently overwrites an explicit value), and threadsrenamedOptionsintogetWorkspaceDirso the--help/--versionshort-circuit paths also resolve--prefixcorrectly.Test plan
cli/parse-cli-args/test/index.ts@pnpm/parse-cli-argspassWritten by an agent (Claude Code, claude-opus-4-7).