Skip to content

[rush-lib] Fix an bug when using pnpm 9, where a subspace is empty, the rush install fails #5044

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

g-chao
Copy link
Contributor

@g-chao g-chao commented Dec 13, 2024

Summary

When using PNPM 9, if a subspace is empty. The rush install will throw follow error:
The shrinkwrap file has not been updated to support workspaces. Run "rush update --full" to update the shrinkwrap file.
However, after rush update --full, then rush install, the error still there.

This is due to, the isWorkspaceCompatible logic does not consider the empty lockfile case.

Here is the current logic:

this.isWorkspaceCompatible =
  this.shrinkwrapFileMajorVersion >= ShrinkwrapFileMajorVersion.V9
    ? this.importers.size > 1
    : this.importers.size > 0;

In a empty lockfile, the importers.size = 1, so I think we will need to change this logic to this.isWorkspaceCompatible = this.importers.size > 0

How it was tested

Manually tested with rush repo locally.

Impacted documentation

N/A

@g-chao
Copy link
Contributor Author

g-chao commented Dec 16, 2024

@fzxen Do you know what's intention to change this this.isWorkspaceCompatible for pnpm9? Right now, when I test it, I found out this logic could not support a empty subspace (which means a empty lockfile) when using pnpm9. So I revert the logic here.

@fzxen
Copy link
Contributor

fzxen commented Dec 18, 2024

@fzxen Do you know what's intention to change this this.isWorkspaceCompatible for pnpm9? Right now, when I test it, I found out this logic could not support a empty subspace (which means a empty lockfile) when using pnpm9. So I revert the logic here.

@g-chao importers.size is always greater than 0 in pnpm lockfile v9
In non-workspace mode, the importers field of lockfilev9 is exists, but it does not in lockfilev6.

importers:
.:
dependencies:
'@pnpm/dependency-path':
specifier: ^5.1.7
version: 5.1.7
'@pnpm/lockfile.utils':
specifier: ^1.0.4
version: 1.0.4
'@rush-temp/project1':
specifier: file:./projects/project1
version: project1@file:projects/project1
'@rush-temp/project2':
specifier: file:./projects/project2
version: project2@file:projects/project2
'@rush-temp/project3':
specifier: file:./projects/project3
version: project3@file:projects/project3
pad-left:
specifier: 1.0.0
version: 1.0.0

Comment on lines -337 to -341
// Lockfile v9 always has "." in importers filed.
this.isWorkspaceCompatible =
this.shrinkwrapFileMajorVersion >= ShrinkwrapFileMajorVersion.V9
? this.importers.size > 1
: this.importers.size > 0;
Copy link
Member

Choose a reason for hiding this comment

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

This check was added in #5009. IIRC there was an explicit reason this was necessary. @fzxen?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants