Skip to content

fix(config): don't let a project manifest choose where machine state lives - #13642

Merged
zkochan merged 103 commits into
mainfrom
claude/sweet-noether-xjt4ai
Aug 15, 2026
Merged

zkochan merged 103 commits into
mainfrom
claude/sweet-noether-xjt4ai

Conversation

@KSXGitHub

@KSXGitHub KSXGitHub commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Resolves #13629.

Every camelCase key of a project's pnpm-workspace.yaml was copied onto the resolved config, and that copy ran after the reader had already resolved the machine-level locations, so the repository won. pnpm login joins opts.configDir with auth.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 directory pnpm setup prepends to the user's PATH and whose shims it deletes; bin, where pnpm install links its dependencies' bins; userConfig, the parsed contents of the user's .npmrc, credentials included; and packageManagerRegistries, where pnpm downloads its own next version, assembled from trustedConfig precisely so repo-controlled config cannot reach it. They are listed in PROJECT_MANIFEST_SKIPPED_KEYS; the reader skips them for the project manifest and warns about the ones it finds.

cacheDir and storeDir stay settable, being deliberate project settings.

pnpm config set refuses the same keys, so the tool does not write a setting the reader will not read. pnpm config delete keeps 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:

// @ts-expect-error
pnpmConfig[key] = value

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_KEYS is 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:

#[serde(rename_all = "camelCase", default)]
pub struct WorkspaceSettings { /* … */ }

configDir, pnpmHomeDir, bin and 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:

  • It only applied inside a workspace. The whole branch is behind if (pnpmConfig.workspaceDir != null).
  • camelCase only. if (!isCamelCase(key)) continue. A hand-written config-dir: never did anything; only configDir: did.
  • CLI options overrode it, since the manifest settings are merged under configFromCliOpts.
  • It moved writes, not reads. By the time the merge runs, the global config.yaml has been read, npmrcAuthFile has been resolved and the .npmrc files loaded ("before loading .npmrc files", per the comment at that site), and configDir has been set from the environment. So a manifest configDir never redirected a read, only consumers that take opts.configDir afterwards, which is exactly pnpm login writing the token.
  • workspaceDir was self-referentially incoherent. The manifest is located via workspaceDir, then overwrites it.
  • pnpm config list confirmed the illusion. The merge does explicitlySetKeys.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 configDir moving pnpm login's token destination, which is the vulnerability itself rather than something anyone would deliberately rely on.

For the reviewer

Bump type. minor throughout. Two new public exports on the reader (isProjectManifestSkippedKey, whereRefusedKeyBelongs), a pnpm config set that 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 wants major. Say the word.

The pnpm config set refusal 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-dir stops 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 --global command 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 breaking stateDir and once for breaking bin. Plain --config-dir is rejected as an unknown option, before and after. It has its own changeset.

Squash Commit Body

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` the directory `pnpm setup` puts on the user's PATH, `bin`
where `pnpm install` links its dependencies' bins, `userConfig` the
parsed contents of the user's own `.npmrc`, and
`packageManagerRegistries` where pnpm downloads its 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, naming the route
that does set each. `cacheDir` and `storeDir` stay settable, being
deliberate project settings. The global config file already filtered its
own keys, but the command line is merged in beside them, so it is
filtered there too; the global package directory's manifest keeps
merging the command line unfiltered.

Guard the reader's own bookkeeping too. The merge writes onto an object
that carries `ConfigContext` beside the settings, so a manifest naming
one of those fields overwrote what the reader had resolved, and
`explicitlySetKeys` crashed every command that reads config when a
manifest gave it anything other than a `Set`.

`pnpm config set` refuses the same keys and names the route that does
set each one. `pnpm config delete` still clears one a file already
carries, in whichever spelling the file used.

pacquet is untouched: it parses the same file into a declared struct, so
these settings were never picked up there in the first place, whereas
pnpm11 copies every key a manifest carries onto the config object and
needs a denylist to be safe.

`--config.config-dir` stops reaching the config through a project
manifest or the global config file. The reader resolves the config
directory from the environment and overwrites the CLI value, so the flag
never worked outside a workspace; inside one it worked only because the
merge re-applied the command line afterwards, and even then it moved
only the write, never the read.

Resolves https://github.com/pnpm/pnpm/issues/13629

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • The change is implemented in both the TypeScript CLI and the Rust
    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.)
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

Written by an agent (Claude Code, Opus 5).

claude added 2 commits August 4, 2026 06:29
…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.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 78939eab-1ed9-4c3d-aa51-9e2c2cd108d0

📥 Commits

Reviewing files that changed from the base of the PR and between 49ea66c and 8364dd8.

📒 Files selected for processing (8)
  • .changeset/config-dir-cli-option-no-longer-applies.md
  • .changeset/config-set-refuses-a-setting-a-project-cannot-hold.md
  • .changeset/project-manifest-cannot-move-machine-state.md
  • pnpm11/config/commands/src/configSet.ts
  • pnpm11/config/commands/test/configSet.test.ts
  • pnpm11/config/reader/src/index.ts
  • pnpm11/config/reader/test/index.ts
  • pnpm11/config/reader/test/whereRefusedKeyBelongs.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/project-manifest-cannot-move-machine-state.md

📝 Walkthrough

Walkthrough

Project workspace manifests can no longer override machine-level paths, authentication, registry, or package-manager network settings. The reader reports refused settings, and configSet rejects writes to those settings while allowing deletion.

Changes

Project manifest setting restrictions

Layer / File(s) Summary
Reader filtering and refusal contract
pnpm11/config/reader/src/index.ts
Defines refused setting groups, filters workspace-manifest values, combines self-update exclusions, and emits destination-specific warnings.
Config set validation and deletion
pnpm11/config/commands/src/configSet.ts
Rejects refused project settings, provides destination-specific hints, and removes alternate key spellings during deletion.
Regression coverage and release metadata
pnpm11/config/reader/test/*, pnpm11/config/commands/test/configSet.test.ts, .changeset/*
Tests filtering, warnings, precedence, rejected writes, deletion semantics, and the documented release changes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 8364d

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
Loading

Possibly related issues

Possibly related PRs

  • pnpm/pnpm#12291: Both changes restrict project-level settings in the configuration reader.
  • pnpm/pnpm#12813: Both changes extend workspace-manifest filtering and refusal logic.
  • pnpm/pnpm#13861: Both changes cover configSet and project-manifest deletion semantics.

Suggested labels: product: pnpm@11

Suggested reviewers: zkochan

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/sweet-noether-xjt4ai

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

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.

❤️ Share

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

@KSXGitHub KSXGitHub left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pnpm11/config/reader/src/index.ts Resolved
Comment thread pnpm11/config/reader/src/index.ts Resolved
claude added 2 commits August 4, 2026 14:16
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
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 4, 2026
@KSXGitHub
KSXGitHub marked this pull request as ready for review August 4, 2026 14:20
@KSXGitHub
KSXGitHub requested a review from zkochan as a code owner August 4, 2026 14:20
Copilot AI lite review requested due to automatic review settings August 4, 2026 14:20
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
@KSXGitHub
KSXGitHub marked this pull request as draft August 4, 2026 14:21

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.changeset/project-manifest-cannot-move-machine-state.md (1)

6-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten 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

📥 Commits

Reviewing files that changed from the base of the PR and between e719786 and 904c360.

📒 Files selected for processing (3)
  • .changeset/project-manifest-cannot-move-machine-state.md
  • pnpm11/config/reader/src/index.ts
  • pnpm11/config/reader/test/index.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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_SETTINGS and applies it unconditionally when importing settings from a project’s pnpm-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.

claude added 12 commits August 4, 2026 14:28
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
@greptile-apps

greptile-apps Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
}

@zkochan
zkochan merged commit ccff081 into main Aug 15, 2026
32 checks passed
@zkochan
zkochan deleted the claude/sweet-noether-xjt4ai branch August 15, 2026 14:50
KSXGitHub pushed a commit that referenced this pull request Aug 18, 2026
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.
KSXGitHub pushed a commit that referenced this pull request Aug 26, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A project's pnpm-workspace.yaml can set configDir, redirecting where pnpm login writes auth.ini

5 participants