Skip to content

[rush-lib] Fix pnpm-sync caused .modules.yaml ENOENT during install#5259

Merged
octogonz merged 3 commits intomicrosoft:mainfrom
harttle:fix-pnpm-sync-modules-yaml
Jun 23, 2025
Merged

[rush-lib] Fix pnpm-sync caused .modules.yaml ENOENT during install#5259
octogonz merged 3 commits intomicrosoft:mainfrom
harttle:fix-pnpm-sync-modules-yaml

Conversation

@harttle
Copy link
Contributor

@harttle harttle commented Jun 23, 2025

Summary

Fixes #5201

During rush install, after calling pnpm install, for repos with injected dependencies enabled, rush calls pnpm-sync.

pnpm-sync then tries to read .modules.yaml during pnpmSyncPrepareAsync(), but this file sometimes doesn't exist, causing rush install to fail.

pnpm itself treats it as a special case and doens't throw when this file not eixst during readModulesManifest() and writeModulesManifest(): https://github.com/pnpm/pnpm/blob/5d2308c9aad8b2a7e96721a13845f21e86038619/pkg-manager/modules-yaml/src/index.ts#L45

Details

Adding one more check for the file before calling pnpmSyncPrepareAsync().

How it was tested

  1. rush install and build this repo
  2. run node libraries/rush-lib/lib-commonjs/start.js install as rush install

if (this.rushConfiguration.isPnpm && experiments?.usePnpmSyncForInjectedDependencies) {
const pnpmLockfilePath: string = subspace.getTempShrinkwrapFilename();
const dotPnpmFolder: string = `${subspace.getSubspaceTempFolderPath()}/node_modules/.pnpm`;
const modulesFilePath: string = `${subspace.getSubspaceTempFolderPath()}/node_modules/.modules.yaml`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally pnpm-sync-lib should export this as a constant. But it's not essential.

@octogonz
Copy link
Collaborator

Thanks for fixing this!

@octogonz octogonz merged commit 7364f99 into microsoft:main Jun 23, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Needs triage to Closed in Bug Triage Jun 23, 2025
@harttle harttle deleted the fix-pnpm-sync-modules-yaml branch June 24, 2025 03:16
@harttle
Copy link
Contributor Author

harttle commented Jun 27, 2025

@octogonz could you also help run a release for rush-lib?

@octogonz
Copy link
Collaborator

@harttle Rush 5.155.1 has been published 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

[rush] "ENOENT: no such file" ../.modules.yaml when installing

2 participants