diff --git a/.changeset/bright-pants-cry.md b/.changeset/bright-pants-cry.md new file mode 100644 index 0000000000..53ba0c9521 --- /dev/null +++ b/.changeset/bright-pants-cry.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Fixing the error `Error: No existing version was accepted for range ^0.12.0, searching through 0.11.2,0.0.0-use.local, for package @backstage/core-components`, which can happen when there are multiple matching versions for a package, and one of them uses `workspace:^` as its range. diff --git a/packages/cli/src/lib/versioning/Lockfile.ts b/packages/cli/src/lib/versioning/Lockfile.ts index 016593ea8d..ab6d98521f 100644 --- a/packages/cli/src/lib/versioning/Lockfile.ts +++ b/packages/cli/src/lib/versioning/Lockfile.ts @@ -190,9 +190,14 @@ export class Lockfile { } // Find all versions currently in use - const versions = Array.from(new Set(entries.map(e => e.version))).sort( - (v1, v2) => semver.rcompare(v1, v2), - ); + const versions = Array.from(new Set(entries.map(e => e.version))) + .map(v => { + // Translate workspace:^ references to the actual version + return v === '0.0.0-use.local' + ? require(`${name}/package.json`).version + : v; + }) + .sort((v1, v2) => semver.rcompare(v1, v2)); // If we're not using at least 2 different versions we're done if (versions.length < 2) {