Skip to content

Resolve ember-cli version from its installed package.json (fixes crash with pnpm catalogs)#1526

Open
NullVoxPopuli wants to merge 1 commit into
ember-cli:mainfrom
NullVoxPopuli:fix/resolve-ember-cli-version-from-package-json
Open

Resolve ember-cli version from its installed package.json (fixes crash with pnpm catalogs)#1526
NullVoxPopuli wants to merge 1 commit into
ember-cli:mainfrom
NullVoxPopuli:fix/resolve-ember-cli-version-from-package-json

Conversation

@NullVoxPopuli

@NullVoxPopuli NullVoxPopuli commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Note

made with claude, and reviewed by me. apologies in advance if I got any of the project's conventions wrong -- happy to adjust.

ember exam --load-balance crashes in any repo using pnpm catalogs, with a cryptic:

TypeError: Cannot read properties of null (reading 'trim')
    at new Range (semver/classes/range.js)
    at outside (semver/ranges/outside.js)
    at Object.gtr (semver/ranges/gtr.js)

we read the ember-cli version out of the app's declared dependency range:

this.emberCliVersion =
  this.project.pkg.devDependencies['ember-cli'] ||
  this.project.pkg.dependencies['ember-cli'];

but with catalogs (and workspace:) that's left verbatim as "catalog:ember-ecosystem" on disk -- pnpm only resolves the alias in the lockfile. so semver.validRange(...) returns null, and validateLoadBalance's semver.gtr('3.2.0', null) blows up on new Range(null).

fix: read the version from ember-cli's own (installed, always-resolved) package.json instead. bonus: it's the version actually in use, not just what's declared.

added a regression test. pnpm test:node green, lint clean.

@NullVoxPopuli
NullVoxPopuli force-pushed the fix/resolve-ember-cli-version-from-package-json branch 2 times, most recently from f931cfe to 345e7cd Compare July 16, 2026 20:55
The `exam` command read the ember-cli version out of the consuming app's
package.json dependency range (`this.project.pkg.devDependencies['ember-cli']`).
That value is not guaranteed to be a concrete semver string: pnpm catalog
(`catalog:`) and workspace (`workspace:`) protocol aliases are left verbatim in
package.json.

When such an alias was present, `validateLoadBalance` passed it to
`semver.validRange`, got `null` back, and then `semver.gtr('3.2.0', null)`
threw `TypeError: Cannot read properties of null (reading 'trim')` — an opaque
crash that took down every `ember exam --load-balance` run.

Read the resolved version from ember-cli's own installed package.json instead,
which always carries a real version regardless of how the app declares the
dependency.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@NullVoxPopuli
NullVoxPopuli force-pushed the fix/resolve-ember-cli-version-from-package-json branch from 345e7cd to 23d76f6 Compare July 16, 2026 20:56
@NullVoxPopuli

Copy link
Copy Markdown
Contributor Author

beta/canary/release are expected to fail for now, because they test app for them needs updating

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates ember exam to derive the Ember CLI version from the installed ember-cli/package.json instead of the host app’s declared dependency range, avoiding semver crashes when the dependency is expressed via pnpm catalogs (catalog:) / workspace:-style specifiers.

Changes:

  • Resolve emberCliVersion from require('ember-cli/package.json').version during command initialization.
  • Add a regression unit test ensuring the resolved version is used even when the declared dependency is a catalog: alias.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
node-tests/unit/commands/exam-test.js Adds a regression test covering pnpm catalog-style dependency specifiers.
lib/commands/exam.js Switches emberCliVersion sourcing to the installed ember-cli package’s version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +45
const command = createCommand();
command.project.pkg.devDependencies['ember-cli'] =
'catalog:ember-ecosystem';
command.init();

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants