Repository navigation
fix(config): don't let a project manifest choose where machine state lives - #13642
Conversation
…lives Every camelCase key in a project's `pnpm-workspace.yaml` was copied into the resolved config wholesale, and that copy ran after the reader had already resolved the machine-level locations from the environment. A repository could therefore redirect where pnpm writes: `configDir` moved the `auth.ini` that `pnpm login` writes the granted token to, `pnpmHomeDir` moved the directory `pnpm setup` puts on the user's PATH (and deletes shims under), `bin` moved where `pnpm install` links its dependencies' bins, and `packageManagerRegistries` moved where pnpm downloads its own next version from. Skip those settings in the project-manifest branch, together with the rest of the locations and trusted-source values the reader derives for itself, and report the ones a manifest tried to set. The global config yaml and the global package directory's manifest are unaffected: both are machine-level, and the former already filters its keys. The Rust stack's `WorkspaceSettings` has no field for any of these, so the two stacks now agree on where `pnpm login` writes. Resolves #13629
The warning claimed every skipped key decides where state that outlives the project lives. That fits `configDir` and `pnpmHomeDir`, but not `dir` or `authConfig`. Name all three groups instead.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughProject workspace manifests can no longer override machine-level paths, authentication, registry, or package-manager network settings. The reader reports refused settings, and ChangesProject manifest setting restrictions
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to This change is merge-ready after normal checks and review; no actionable merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant WorkspaceManifest as pnpm-workspace.yaml
participant ConfigReader
participant ConfigSet
participant ConfigFile
WorkspaceManifest->>ConfigReader: provides project settings
ConfigReader->>ConfigReader: filters refused keys and formats warnings
ConfigReader-->>ConfigSet: exposes project-setting restrictions
ConfigSet->>ConfigSet: validates writes or deletion requests
ConfigSet->>ConfigFile: writes permitted keys or removes refused keys
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
KSXGitHub
left a comment
There was a problem hiding this comment.
Claude Code,
Below are many different reviews. Each may belong to different categories.
I wish that you do not collapse all the unrelated tasks into a single commit.
You shall analyze the reviews. You shall make groups of related reviews.
Each group of related reviews correspond to a task and a git commit.
A git commit should have its purpose clear and focused.
If there would be multiple groups of related reviews, then I expect multiple commits.
The block walked through one example per skipped key. The set's contract is just that these come from trusted sources and a repository could only redirect a write; the per-command detail belongs in the commit history. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
The trailing sentence justified the policy rather than telling the user what to do about it, and no other config warning explains itself at that length. Keep the list of ignored keys. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
Mutation testing found the gap: reverting the `forSelfUpdate` branch to `? SELF_UPDATE_SKIPPED_SETTINGS` makes a project manifest able to move `configDir` again during `pnpm self-update`, and nothing failed. Nothing exercised `forSelfUpdate` alongside the new skips. The test asserts both directions of the union, so trading either set for the other now fails. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.changeset/project-manifest-cannot-move-machine-state.md (1)
6-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten the changeset entry.
The release note is too detailed for user-facing release metadata. Describe the behavior change and warning in one or two sentences. Keep the protected-key inventory and implementation rationale in the PR description.
As per path instructions, keep the changeset concise and user-facing.
Proposed release note
-A project's `pnpm-workspace.yaml` can no longer decide where pnpm reads and writes state that outlives the project. `configDir` set in a repository redirected the `auth.ini` that `pnpm login` writes the granted token to; `pnpmHomeDir` redirected the directory `pnpm setup` puts on the user's PATH; `bin` redirected where `pnpm install` links its dependencies' bins; and `packageManagerRegistries` redirected where pnpm downloads its own next version from. These settings, along with `dir`, `globalPkgDir`, `npmrcAuthFile`, `rootProjectManifestDir`, `userconfig`, `workspaceDir`, `authConfig`, `configByUri`, and `packageManagerNetworkConfig`, now come from the environment, the global config file, and the command line only, and a project manifest that sets one of them is reported as ignored [`#13629`](https://github.com/pnpm/pnpm/issues/13629). +Prevent project `pnpm-workspace.yaml` files from overriding machine-level paths and authentication or bootstrap settings. pnpm now ignores and warns about these settings [`#13629`](https://github.com/pnpm/pnpm/issues/13629).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.changeset/project-manifest-cannot-move-machine-state.md at line 6, Shorten the changeset entry to one or two user-facing sentences stating that protected pnpm state/configuration settings can no longer be set through a project manifest and that such settings are reported as ignored. Remove the detailed key inventory, examples, rationale, and issue link; retain that implementation detail in the PR description instead.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.changeset/project-manifest-cannot-move-machine-state.md:
- Line 6: Shorten the changeset entry to one or two user-facing sentences
stating that protected pnpm state/configuration settings can no longer be set
through a project manifest and that such settings are reported as ignored.
Remove the detailed key inventory, examples, rationale, and issue link; retain
that implementation detail in the PR description instead.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ef4f240f-e775-441a-b94d-c0e1e4363290
📒 Files selected for processing (3)
.changeset/project-manifest-cannot-move-machine-state.mdpnpm11/config/reader/src/index.tspnpm11/config/reader/test/index.ts
There was a problem hiding this comment.
🟢 Ready to approve
The change is narrowly scoped, security-motivated, and is backed by targeted regression tests and a changeset.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR hardens the TypeScript config reader so a repository’s pnpm-workspace.yaml can no longer override machine-level locations or trusted config inputs (e.g. configDir / auth.ini path), preventing project-controlled redirection of where pnpm reads/writes sensitive or machine-scoped state.
Changes:
- Introduces
PROJECT_MANIFEST_SKIPPED_SETTINGSand applies it unconditionally when importing settings from a project’spnpm-workspace.yaml. - Adds a warning when a project manifest attempts to set any of the now-ignored keys.
- Adds regression tests covering the blocked keys (and that benign/project-owned settings still work), plus a changeset for the patch.
File summaries
| File | Description |
|---|---|
| pnpm11/config/reader/src/index.ts | Skips a new allow/deny set of project-manifest keys and emits warnings when ignored keys are present. |
| pnpm11/config/reader/test/index.ts | Adds regression tests ensuring project manifests cannot redirect machine/trusted locations while still allowing project-owned settings. |
| .changeset/project-manifest-cannot-move-machine-state.md | Documents the behavior change and ships it as a patch release. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
The assertion list restated the fixture's keys minus the two asserted separately, so a setting added to both the skip set and the fixture would have gone unchecked. Iterate the fixture instead, asserting each key both equals the value the reader resolved and is not the value the manifest asked for. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
…onfig The release note and the doc comment both said these settings now come from the environment, the global config file, and the command line only. That is wrong for most of them: `isConfigFileKey` rejects `config-dir`, `dir`, `bin`, and `pnpm-home-dir`, and the derived fields are settable in no config source at all. Only `npmrc-auth-file` and `userconfig` are valid there. Drop the claim, and drop the list of internal field names from the release note — it named `rootProjectManifestDir` and friends as if users could set them. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
This diff made `keys.map(k => `"${k}"`).join(', ')` the third copy in the file,
alongside the global-config-file warning and the package.json "pnpm" field
warning. The three have to stay formatted alike for the reporter's output to
look consistent, so give them one function.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
…anifest I left `stateDir`, `globalDir`, and `globalBinDir` settable on the premise that a project `.npmrc` could set them anyway, so denying them in the yaml alone would be a half-measure. That premise is wrong: `isNpmrcReadableKey` admits only auth keys, scoped keys, and the six network keys, so an `.npmrc` in a repository reaches none of them. In pnpm 11 the project manifest is the only repo-controlled source for a setting. On their own merits all three are machine-level — none appears in the Rust `WorkspaceSettings`, and all three are valid in the global config file, which is where they belong. `stateDir` is the live one: it is resolved after the manifest merge, so a repository could move the `pnpm-state.json` that the update check writes. `globalDir` and `globalBinDir` are inert only positionally — they are read before the merge, and `--global` never reads a project manifest at all. `cacheDir` and `storeDir` stay settable. Those are deliberate project settings with fields in the Rust `WorkspaceSettings`. The new test pins the other direction: `--global-bin-dir`, `--global-dir`, and `PNPM_CONFIG_STATE_DIR` still win over a manifest that names all three. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
`packageManagerNetworkConfig.strictSsl` comes from `trustedConfig`, which merges the real `~/.npmrc`, so asserting it is `undefined` failed on any machine with `strict-ssl` set there. The manifest in the test also set `strictSsl: false`, so the assertion could not tell "the manifest was ignored" from "the npmrc happened to agree". Compare all four values against a no-manifest baseline, the way the sibling tests do, and have the manifest ask for the negation of the resolved value so agreement can never mask a leak. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
`pnpm config set --location=project` routes any camelCase key into `pnpm-workspace.yaml`, including the ones the reader now skips. Setting `configDir` that way left the user with a value that does nothing and a warning on every subsequent command, naming no remedy. Reject those keys up front instead, the way the global config file already rejects its own unsupported keys, and export the predicate from the reader so the two stay in step. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
It ran four exploit narratives long. A release note should say what changed for the reader; the inventory of protected keys and the reasoning behind it belong in the pull request. Keep the issue link, which this repository's release notes carry by convention. Also declare `@pnpm/config.commands`, which this change now touches. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
`expect.objectContaining(...) as PnpmError` does not typecheck under the repository-wide build, which is stricter than the package build that let it through. Use `rejects.toMatchObject`, the shape the neighbouring error assertions in this file already use. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
… has `pnpm config delete` reaches `configSet` with a null value, so the rejection I added refused it too. A repository that already carries `configDir` in its `pnpm-workspace.yaml` would warn on every command while the documented way to clear it — `pnpm config delete config-dir` — failed, leaving hand-editing the yaml as the only way out. Refuse writes only. Deleting one of these is the remedy, not the problem. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
The doc comment, the release note, and the new error hint all said pnpm resolves these settings before it reads the project manifest. That is false for the three added last: `stateDir` gets its default after the merge, and `globalDir` and `globalBinDir` are never resolved by the reader at all — they stay unset unless the CLI, the environment, or the global config names them. Say what actually unites them instead: they name what the machine keeps and which directories the command operates on, none of which is the project's to choose. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
`pnpm config set --global config-dir …` told the user to set it in the local pnpm-workspace.yaml instead — the one place that now refuses it too, so the advice sent them in a circle. Machine-level keys have no config file at all; say so for those and leave the hint alone for everything else. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
The CLI/env guard passed `dir: process.cwd()`, which the reader would have produced anyway, so the fixture asserted nothing. Point it at a real subdirectory and check the resolved value, so the guard covers `--dir` — the one denied key with a CLI flag people reach for. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KSas3DxDW1so5zoVvSdvj5
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Suppressed comments (3)
pnpm11/config/commands/src/configSet.ts:208
- hintForRefusedKey() only treats isProjectManifestSkippedKey() keys as "refused by the project manifest". But the reader also refuses CONFIG_CONTEXT keys (like "packageManager") from pnpm-workspace.yaml, so
pnpm config set --global packageManager ...would still hint to move it to pnpm-workspace.yaml even though the reader will ignore it there too.
/** The suggestion for {@link key}, which falls back when the key is allowed in a project manifest. */
function hintForRefusedKey (key: string, fallback: string): string {
const camelKey = camelCase(key)
if (!isProjectManifestSkippedKey(camelKey)) return fallback
return whereRefusedKeyBelongs(camelKey)
}
pnpm11/config/commands/src/configSet.ts:64
- The project-manifest write guard only checks isProjectManifestSkippedKey(), but the config reader also refuses CONFIG_CONTEXT keys (e.g. "explicitlySetKeys", "packageManager", "cliOptions") during workspace-manifest merging. As-is,
pnpm config set --location=project explicitlySetKeys ...(camelCase) will happily write a key that the reader ignores and warns about, which contradicts the goal of not writing settings the reader won't read.
This issue also appears on line 203 of the same file.
const writtenKey = isRemoval ? camelCase(key) : validateWorkspaceKey(key)
if (castValue != null && configFileName === WORKSPACE_MANIFEST_FILENAME && isProjectManifestSkippedKey(writtenKey)) {
throw new ConfigSetNotAProjectSettingError(writtenKey)
}
pnpm11/config/reader/src/index.ts:1218
- isRefusedByAProjectManifest() captures the true "project manifest refusal" policy (skipped settings + CONFIG_CONTEXT keys + kebab→camel normalization), but it is file-local. configSet.ts currently reimplements a weaker check (isProjectManifestSkippedKey only), which can drift and already causes incorrect hints/refusal behavior for CONFIG_CONTEXT keys.
/**
* Whether a project's `pnpm-workspace.yaml` drops {@link key}, given in either
* camelCase or kebab-case, whether as a value a project may not contribute or
* as the reader's own bookkeeping.
*
* Shared by the warnings so that they cannot disagree on what was dropped.
*/
function isRefusedByAProjectManifest (key: string): boolean {
const camelKey = camelcase(key, { locale: 'en-US' })
return isProjectManifestSkippedKey(camelKey) || CONFIG_CONTEXT_KEY_SET.has(camelKey)
}
Five conflicts, all from main growing its own version of what this branch touches. The Rust crates were renamed from `pacquet-` to `pnpm-` (#13948), so every `pacquet_config::` path in the new code moved with them, and `cli_args/config_warnings.rs` picked up a second warning (`warn_unmatched_registry_options`) beside this branch's emit-once drain. Both halves are additive: the file keeps both, and its test module keeps both test sets. `crates/cli/tests/` is now a single target whose modules live in `tests/suite/` (#13679). Git moved `login.rs` for us but left this branch's new `config_warnings.rs` at the old path, where it would have become its own ~240 MB binary; it moves into `tests/suite/` and is declared in `main.rs`. The substantive one is the config reader. This branch hand-rolled a `REPO_MANIFEST_SKIPPED_SETTINGS` denylist plus a bespoke `IGNORED_SCOPE_WARNING`, and main has since generalized exactly that concept: `PROJECT_MANIFEST_SKIPPED_KEYS`, assembled from the machine locations, the current run's locations, and the credential keys, with one warning that names each refused key and the route that does set it (#13642). Keeping both would leave two denylists answering the same question, so `scope` joins main's as a `LOGIN_TARGET_KEYS` category and the bespoke set and constant are dropped. Users get the unified sentence, which also names the global command, and `pnpm config set scope` in a project now refuses with that same route rather than writing a key the reader would ignore. pacquet has no such mechanism — main left it untouched, since it parses the manifest into a declared struct — so its `IGNORED_SCOPE_WARNING` is reworded to the sentence the TypeScript reader now assembles, keeping the two stacks emitting identical text. The `Config.ts` note on the field goes away with it: main keeps this fact only in the denylist, and `configDir` and its peers carry no such note.
Three conflicts, and behind them the same story as the last merge, now on the other stack: main has grown the general mechanism this branch built a private one for. pacquet gained the refused-key machinery #13642 had only given the TypeScript reader — `refused_keys`, `WorkspaceKeyIssues`, and a `report_workspace_key_issues` the CLI calls once per command from `pre_command`. That is a better home for the login scope than this branch's own channel, so `scope` joins pacquet's `PROJECT_MANIFEST_SKIPPED_KEYS` (the mirror of the TypeScript list it already joined), is zeroed beside `ci` and `stateDir` where the project manifest is applied, and the warning is assembled from the key like every other refused one. That retires the rest of the branch's pacquet side. `IGNORED_SCOPE_WARNING` and `clear_repo_scope` are gone; so is `Config::config_warnings`, whose only producer they were, along with the CLI's `drain_config_warnings`, the process-wide emitted set behind it, and the end-to-end test for the once-per-command rule it enforced. Reporting from `pre_command` gives that rule by construction — the report happens at one point per command rather than on every config load — so the rule is kept and the machinery for it is not. The unit tests that drove `clear_repo_scope` move to the mechanisms that now carry their subject: the refusal and its global route to `refused_keys`, and an empty `scope:` still counting as a value to `collect_key_issues`. The end-to-end login test stays where it is, since what it proves — the repo's scope reaches neither stderr's silence nor `auth.ini` — is unchanged, and asserts the assembled sentence. Main also landed `Config::scope`, its `PNPM_CONFIG_SCOPE` overlay, and the `--scope` fallback that reads it, so the branch no longer adds them. Its pending changeset for that still advertised `pnpm-workspace.yaml` as one of the sources; this branch already trims that line, and the trim now applies to main's copy.
Summary
Resolves #13629.
Every camelCase key of a project's
pnpm-workspace.yamlwas copied onto the resolved config, and that copy ran after the reader had already resolved the machine-level locations, so the repository won.pnpm loginjoinsopts.configDirwithauth.ini, which is the reported case: clone a repository, log in, and the token lands wherever the repository said.The issue asks for the rest of the class. Probing the reader with a manifest of every location-shaped key turned up seventeen. The sharpest are
pnpmHomeDir, the directorypnpm setupprepends to the user's PATH and whose shims it deletes;bin, wherepnpm installlinks its dependencies' bins;userConfig, the parsed contents of the user's.npmrc, credentials included; andpackageManagerRegistries, where pnpm downloads its own next version, assembled fromtrustedConfigprecisely so repo-controlled config cannot reach it. They are listed inPROJECT_MANIFEST_SKIPPED_KEYS; the reader skips them for the project manifest and warns about the ones it finds.cacheDirandstoreDirstay settable, being deliberate project settings.pnpm config setrefuses the same keys, so the tool does not write a setting the reader will not read.pnpm config deletekeeps working, in whichever spelling the file uses, since clearing an affected manifest is the remedy the warning implies.A second guard covers the reader's own bookkeeping. The resolved config holds more than settings: it also carries what the reader worked out for itself, and a manifest naming one of those fields overwrote it — in the worst case with a value of the wrong type, which crashed every command that reads config. Those fields are now refused outright, and an explicit proof keeps the list exhaustive: the typechecker fails if the reader gains a field nobody has classified.
This is a pnpm11-only change
The bug is a property of pnpm11's config-loading mechanism, not of pnpm's design, which is why the patch belongs to one stack.
pnpm11 merges a project manifest by copying every key onto the config object:
The set of settings a manifest may contribute is not declared anywhere. It is whatever the file happens to contain. TypeScript objects to that assignment, and the objection is suppressed. Any key the file carries lands on the config, so the machine-level locations were reachable simply because nothing said they weren't.
PROJECT_MANIFEST_SKIPPED_KEYSis the denylist that mechanism needs in order to be safe.pacquet loads the same file into a declared struct, so the set of settable keys is the type:
configDir,pnpmHomeDir,binand the rest are not fields, so serde drops them at parse time. There is nothing to skip, because they were never picked up. pacquet needs no denylist, and adding one would guard against a path that does not exist. A repository has never been able to redirect these on that side, so there is also no behavior being withdrawn and nothing to announce.What the removed behavior was actually worth
Whether this removal breaks anything depends on what a repository could actually achieve by setting these keys, and the answer is: very little. The behaviour looked sweeping — any camelCase key redirecting a machine-level location — but reading the merge site (
addSettingsFromWorkspaceManifestToConfig) against the load order, it was narrow at every point that mattered:if (pnpmConfig.workspaceDir != null).if (!isCamelCase(key)) continue. A hand-writtenconfig-dir:never did anything; onlyconfigDir:did.configFromCliOpts.config.yamlhas been read,npmrcAuthFilehas been resolved and the.npmrcfiles loaded ("before loading .npmrc files", per the comment at that site), andconfigDirhas been set from the environment. So a manifestconfigDirnever redirected a read, only consumers that takeopts.configDirafterwards, which is exactlypnpm loginwriting the token.workspaceDirwas self-referentially incoherent. The manifest is located viaworkspaceDir, then overwrites it.pnpm config listconfirmed the illusion. The merge doesexplicitlySetKeys.add(key), so the setting was reported as explicitly set while the reads had already used the real value.So for most of the seventeen keys this PR refuses, there was nothing to depend on. The one with a load-bearing effect was
configDirmovingpnpm login's token destination, which is the vulnerability itself rather than something anyone would deliberately rely on.For the reviewer
Bump type.
minorthroughout. Two new public exports on the reader (isProjectManifestSkippedKey,whereRefusedKeyBelongs), apnpm config setthat refuses input it used to accept, and settings that stop working in a project manifest. If you read that last part as breaking rather than as a fix, this wantsmajor. Say the word.The
pnpm config setrefusal is an addition nobody asked for, and it is yours to reject. Neither the issue nor the review requested it; the agent added it on its own judgement. For: a loud error is better than a silent failure, since without it the command writes a key the reader ignores. Against: nobody would set these in a project manifest anyway, so it buys little for the code complexity it adds. A question of values rather than correctness, so it is yours.--config.config-dirstops reaching the config through a project manifest. The reader resolves the config directory from the environment and overwrites whatever the CLI supplied, so the flag never worked outside a workspace. Inside one it worked only because the manifest merge re-applied the CLI options afterwards, and even then it moved only the write. Filtering that merge removes the leftover re-application. A--globalcommand that finds a manifest in the global package directory still merges the command line unfiltered, so the flags survive in that corner; narrowing that branch was tried twice on this branch and reverted twice, once for breakingstateDirand once for breakingbin. Plain--config-diris rejected as an unknown option, before and after. It has its own changeset.Squash Commit Body
Checklist
already linked to it solves it.
pnpm/port, or the description notes what still needs porting.(pnpm11-only; "This is a pnpm11-only change" explains why the flaw cannot
exist in pacquet's loader.)
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, Opus 5).