Skip to content

fix(config): handle configDependencies fetch during config commands#10688

Draft
ishan8351 wants to merge 1 commit into
pnpm:mainfrom
ishan8351:fix-config-deps-fetch
Draft

fix(config): handle configDependencies fetch during config commands#10688
ishan8351 wants to merge 1 commit into
pnpm:mainfrom
ishan8351:fix-config-deps-fetch

Conversation

@ishan8351

@ishan8351 ishan8351 commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Running pnpm config set with configDependencies triggers installConfigDeps before saving
the new config, causing a crash as it tries to download dependencies before auth token is
written to .npmrc.

This PR adds an catchConfigDependenciesErrors flag to getConfig. During config commands
(config, set, get), if an error occurs, catches and logs it and proceeds.

Fixes #10684

@ishan8351 ishan8351 requested a review from zkochan as a code owner February 25, 2026 10:53
@ishan8351

Copy link
Copy Markdown
Contributor Author

pnpm audit is failing currently, but it is unrelated to changes made in this PR

@zkochan zkochan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

test coverage is needed.

Comment thread cli/cli-utils/src/getConfig.ts Outdated
})
config.cliOptions = cliOptions
if (config.configDependencies) {
if (config.configDependencies && !opts.ignoreConfigDependencies) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe run it anyway but ignore the errors

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

This PR addresses a pnpm CLI crash where running pnpm config set in a workspace with configDependencies could trigger an early config-deps fetch (before the auth token is written), leading to 401 failures.

Changes:

  • Adds an ignoreConfigDependencies option to @pnpm/cli-utils getConfig() to skip installing configDependencies.
  • Enables that option from the CLI entrypoint for the config command.
  • Adds a changeset for @pnpm/cli-utils.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pnpm/src/main.ts Passes ignoreConfigDependencies based on the active command to avoid early config-deps installs.
cli/cli-utils/src/getConfig.ts Introduces the ignoreConfigDependencies option and guards the config-deps install.
.changeset/major-hats-press.md Declares a patch bump for @pnpm/cli-utils related to config-deps fetching behavior.
Comments suppressed due to low confidence (1)

cli/cli-utils/src/getConfig.ts:37

  • When opts.ignoreConfigDependencies is true, installConfigDeps() is skipped, but later the code still derives pnpmfile paths from config.configDependencies and passes them to requireHooks(). requireHooks() throws PNPMFILE_NOT_FOUND for non-optional pnpmfiles, so pnpm config/pnpm set can now fail if configDependencies include a plugin (e.g. pnpm-plugin-*) whose pnpmfile isn't installed yet. Consider also guarding the pnpmfile injection with !opts.ignoreConfigDependencies (or marking these derived pnpmfiles as optional) to avoid breaking config commands.
  if (config.configDependencies && !opts.ignoreConfigDependencies) {
    const store = await createStoreController(config)
    await installConfigDeps(config.configDependencies, {
      registries: config.registries,
      rootDir: config.lockfileDir ?? config.rootProjectManifestDir,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pnpm/src/main.ts
Comment thread .changeset/major-hats-press.md
Comment thread pnpm/src/main.ts Outdated
@ishan8351 ishan8351 force-pushed the fix-config-deps-fetch branch from 7047c5b to e6ca98c Compare February 28, 2026 12:00
@ishan8351 ishan8351 changed the title fix(config): skip configDependencies fetch during config commands fix(config): handle configDependencies fetch during config commands Feb 28, 2026
@ishan8351

Copy link
Copy Markdown
Contributor Author

updated

Running pnpm config set with configDependencies triggers installConfigDeps before saving
the new config, causing a crash as it tries to download dependencies before auth token is
written to .npmrc.

This commit adds an catchConfigDependenciesErrors flag to getConfig. During config commands
(config, set, get), if an error occurs, catches and logs it and proceeds.

Fixes pnpm#10684
@ishan8351 ishan8351 force-pushed the fix-config-deps-fetch branch from e6ca98c to 5377b33 Compare February 28, 2026 12:19
@ishan8351 ishan8351 requested a review from zkochan February 28, 2026 13:03
@fpapado

fpapado commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

@zkochan and @ishan8351, is there something blocking this PR, or did it just incidentally fall by the wayside?

I ask because we are facing a similar issue at work: we are introducing a shared config dependency for security hardening, but said config dependency (and our packages in general) is behind auth. Thus, pnpm config set ... fails for most teams' setups after adding the config dependency.

While we could work around it with a .npmrc / npm config set dance, this is not as simple as pnpm add --config ..., which slows down adoption. I'd be happy to pick up this PR or help unblock it, if it is ok with both of you 😌

@ishan8351

Copy link
Copy Markdown
Contributor Author

Hey @fpapado, this is one of a bunch of PRs I opened, then I got occupied somewhere else. Please do take a look, if my implementation's alright and solves your problem, I'll try to finish it. Or you're welcome to take it over.

@fpapado

fpapado commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Hey @fpapado, this is one of a bunch of PRs I opened, then I got occupied somewhere else. Please do take a look, if my implementation's alright and solves your problem, I'll try to finish it. Or you're welcome to take it over.

Yay, thank you for the response! Main had drifted a bit since this PR was opened, so I made a new set of changes here with a few more integration tests here #11362 🗒️

@ishan8351 ishan8351 marked this pull request as draft May 12, 2026 16:18
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.

pnpm config set inconsistently installs config dependencies

4 participants