diff --git a/.changeset/three-islands-juggle.md b/.changeset/three-islands-juggle.md new file mode 100644 index 0000000000..a4d2dff2c3 --- /dev/null +++ b/.changeset/three-islands-juggle.md @@ -0,0 +1,6 @@ +--- +"@pnpm/resolve-dependencies": patch +pnpm: patch +--- + +When using pnpm catalogs and running a normal `pnpm install`, pnpm produced false positive warnings for "_skip adding to the default catalog because it already exists_". This warning now only prints when using `pnpm add --save-catalog` as originally intended. diff --git a/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts b/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts index 727f0a564f..1ec1a93b31 100644 --- a/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts +++ b/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts @@ -245,6 +245,11 @@ export async function resolveDependencyTree ( for (const directDependencies of pkgAddressesByImporters) { for (const directDep of directDependencies as PkgAddress[]) { const { alias, normalizedBareSpecifier, version, saveCatalogName } = directDep + + if (saveCatalogName == null) { + continue + } + const existingCatalog = opts.catalogs?.default?.[alias] if (existingCatalog != null) { if (existingCatalog !== normalizedBareSpecifier) { @@ -252,7 +257,7 @@ export async function resolveDependencyTree ( `Skip adding ${alias} to the default catalog because it already exists as ${existingCatalog}. Please use \`pnpm update\` to update the catalogs.` ) } - } else if (saveCatalogName != null && normalizedBareSpecifier != null && version != null) { + } else if (normalizedBareSpecifier != null && version != null) { const userSpecifiedBareSpecifier = `catalog:${saveCatalogName === 'default' ? '' : saveCatalogName}` // Attach metadata about how this new catalog dependency should be