Skip to content

Commit

Permalink
[rush] Skip unrelated projects shrinkwrap-deps during state snapshot (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-gomes-92 authored Dec 2, 2024
1 parent 0c32d6d commit dd871b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Fix an issue where Rush sometimes incorrectly reported \"fatal: could not open 'packages/xxx/.rush/temp/shrinkwrap-deps.json' for reading: No such file or directory\" when using subspaces",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
24 changes: 11 additions & 13 deletions libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,25 +257,23 @@ export class ProjectChangeAnalyzer {
const additionalRelativePathsToHash: string[] = [];
const globalAdditionalFiles: string[] = [];
if (rushConfiguration.packageManager === 'pnpm') {
const absoluteFilePathsToCheck: string[] = [];

for (const project of rushConfiguration.projects) {
await Async.forEachAsync(rushConfiguration.projects, async (project: RushConfigurationProject) => {
const projectShrinkwrapFilePath: string = BaseProjectShrinkwrapFile.getFilePathForProject(project);
absoluteFilePathsToCheck.push(projectShrinkwrapFilePath);
const relativeProjectShrinkwrapFilePath: string = Path.convertToSlashes(
path.relative(rootDirectory, projectShrinkwrapFilePath)
);

additionalRelativePathsToHash.push(relativeProjectShrinkwrapFilePath);
}
if (!(await FileSystem.existsAsync(projectShrinkwrapFilePath))) {
if (rushConfiguration.subspacesFeatureEnabled) {
return;
}

await Async.forEachAsync(absoluteFilePathsToCheck, async (filePath: string) => {
if (!rushConfiguration.subspacesFeatureEnabled && !(await FileSystem.existsAsync(filePath))) {
throw new Error(
`A project dependency file (${filePath}) is missing. You may need to run ` +
`A project dependency file (${projectShrinkwrapFilePath}) is missing. You may need to run ` +
'"rush install" or "rush update".'
);
}

const relativeProjectShrinkwrapFilePath: string = Path.convertToSlashes(
path.relative(rootDirectory, projectShrinkwrapFilePath)
);
additionalRelativePathsToHash.push(relativeProjectShrinkwrapFilePath);
});
} else {
// Add the shrinkwrap file to every project's dependencies
Expand Down

0 comments on commit dd871b9

Please sign in to comment.