Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Fix an issue in pnpm9, where a subspace is empty, the rush install fails",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
16 changes: 11 additions & 5 deletions libraries/rush-lib/src/logic/pnpm/PnpmShrinkwrapFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class PnpmShrinkwrapFile extends BaseShrinkwrapFile {
// Lockfile v9 always has "." in importers filed.
this.isWorkspaceCompatible =
this.shrinkwrapFileMajorVersion >= ShrinkwrapFileMajorVersion.V9
? this.importers.size > 1
? this.importers.size >= 1
: this.importers.size > 0;
g-chao marked this conversation as resolved.
Show resolved Hide resolved

this._integrities = new Map();
Expand All @@ -355,7 +355,7 @@ export class PnpmShrinkwrapFile extends BaseShrinkwrapFile {
if (/https?:/.test(version)) {
return /@https?:/.test(version) ? version : `${name}@${version}`;
} else if (/file:/.test(version)) {
return /@file:/.test(version)? version : `${name}@${version}`;
return /@file:/.test(version) ? version : `${name}@${version}`;
}

return dependencyPath.removeSuffix(version).includes('@', 1) ? version : `${name}@${version}`;
Expand Down Expand Up @@ -556,7 +556,8 @@ export class PnpmShrinkwrapFile extends BaseShrinkwrapFile {
private _convertLockfileV6DepPathToV5DepPath(newDepPath: string): string {
if (!newDepPath.includes('@', 2) || newDepPath.startsWith('file:')) return newDepPath;
const index: number = newDepPath.indexOf('@', newDepPath.indexOf('/@') + 2);
if (newDepPath.includes('(') && index > dependencyPathLockfilePreV9.indexOfPeersSuffix(newDepPath)) return newDepPath;
if (newDepPath.includes('(') && index > dependencyPathLockfilePreV9.indexOfPeersSuffix(newDepPath))
return newDepPath;
return `${newDepPath.substring(0, index)}/${newDepPath.substring(index + 1)}`;
}

Expand All @@ -570,7 +571,8 @@ export class PnpmShrinkwrapFile extends BaseShrinkwrapFile {
if (this.shrinkwrapFileMajorVersion >= 6) {
depPath = this._convertLockfileV6DepPathToV5DepPath(packagePath);
}
const pkgInfo: ReturnType<typeof dependencyPathLockfilePreV9.parse> = dependencyPathLockfilePreV9.parse(depPath);
const pkgInfo: ReturnType<typeof dependencyPathLockfilePreV9.parse> =
dependencyPathLockfilePreV9.parse(depPath);
return this._getPackageId(pkgInfo.name as string, pkgInfo.version as string);
}

Expand Down Expand Up @@ -1126,7 +1128,11 @@ export class PnpmShrinkwrapFile extends BaseShrinkwrapFile {
let resolvedVersion: string = this.overrides.get(name) ?? version;
// convert path in posix style, otherwise pnpm install will fail in subspace case
resolvedVersion = Path.convertToSlashes(resolvedVersion);
if (specifierFromLockfile.specifier !== resolvedVersion && !isDevDepFallThrough && !isOptional) {
if (
specifierFromLockfile.specifier !== resolvedVersion &&
!isDevDepFallThrough &&
!isOptional
) {
return true;
}
}
Expand Down
Loading