GeezerVison is showing github.com — feat(cli): warn on global local version mismatch by Iineman2 · Pull Request #29546 · prisma/orm
Conversation
/claim #1911
Summary
- add a global/local Prisma version mismatch warning to
prisma generate
- compare the running global CLI version against local
prisma and @prisma/client versions when the CLI is installed globally
- avoid noisy false positives for non-exact specifiers such as
workspace:* or dist tags
- include project-package-manager-specific guidance (
npx, pnpm, yarn, or bun) so users can run the local Prisma CLI
Verification
nvm use 20.19.4; pnpm --filter prisma test -- src/__tests__/version-mismatch-warning.test.ts
nvm use 20.19.4; pnpm exec turbo build --filter=prisma
git diff --check HEAD~1 HEAD
Note: I also added focused Generate.test.ts coverage for the user-facing generate output path, but the full Generate.test.ts fixture suite is blocked on this Windows environment by symlink permissions (EPERM: operation not permitted, symlink ... node_modules/@prisma/client). The helper suite and filtered CLI build pass locally.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
May 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8209e004-7c4c-4f52-8b1e-736f579a77d9
📥 Commits
Reviewing files that changed from the base of the PR and between 084dd9c and 51ace9a.
📒 Files selected for processing (1)
packages/cli/src/utils/version-mismatch-warning.ts
Summary by CodeRabbit
-
New Features
- CLI generate now surfaces a global/local version-mismatch warning in its output (including when the JS client generator is absent), and shows the appropriate package-manager command to resolve it.
-
Bug Fixes
- Ensure the version-mismatch warning appears even when hints are otherwise suppressed.
-
Tests
- Added extensive tests covering mismatch detection, formatting, normalization, and package-manager detection.
Walkthrough
This PR adds detection and display of version mismatch warnings when a globally installed Prisma CLI differs from locally declared Prisma packages in a project. A new utility module detects mismatches, normalizes versions, infers package managers, and formats warnings. The Generate command integrates this utility to display warnings in output, with comprehensive test coverage.
Changes
Version Mismatch Warning Detection & Display
| Layer / File(s) |
Summary |
Utility Module & Core Orchestration packages/cli/src/utils/version-mismatch-warning.ts |
getVersionMismatchWarning orchestrates version mismatch detection: validates global install, normalizes versions, reads local package.json versions, detects package manager (pnpm/yarn/bun/npm), computes mismatches for prisma and @prisma/client, and returns formatted warning with appropriate generate command or null if no mismatch. |
Helper Functions & Formatters packages/cli/src/utils/version-mismatch-warning.ts |
formatVersionMismatchWarning formats detected mismatches with package-manager-specific commands. Internal helpers: findMismatch (builds mismatch objects when versions differ), getPackageJsonVersion (reads local versions from package.json dependencies), normalizeVersion (normalizes version strings; returns null for workspace:* or non-semver), detectPackageManagerFromProject (infers from lockfiles/package.json), getPrismaGenerateCommand (maps package manager to command). |
Generate Command Integration packages/cli/src/Generate.ts |
Generate class now accepts optional versionMismatchWarningOptions in constructor. During non-watch parse runs, computes globalLocalVersionWarning via getVersionMismatchWarning. Hint assembly includes the version warning even when no JS client generator is found, allowing warning display for all execution paths. |
Tests packages/cli/src/__tests__/version-mismatch-warning.test.ts, packages/cli/src/__tests__/commands/Generate.test.ts |
Unit tests verify getVersionMismatchWarning returns null when no global install or versions match, returns formatted warning for @prisma/client/prisma mismatches with correct package-manager commands, and handles unsafe version comparisons. Tests for normalizeVersion (exact, caret, tilde, prerelease) and formatVersionMismatchWarning output format. Integration tests verify Generate includes mismatch warning in output and respects --no-hints flag (warning persists, standard hints omitted). |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
⚠️ Warning |
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name |
Status |
Explanation |
| Title check |
✅ Passed |
The title accurately describes the main feature added: warning on global-local version mismatch in the CLI. |
| Description check |
✅ Passed |
The description is detailed and directly related to the changeset, explaining the feature's purpose, implementation approach, and verification steps. |
| Linked Issues check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
✨ Simplify code
- Create PR with simplified code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
All committers have signed the CLA.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cli/src/utils/version-mismatch-warning.ts`:
- Around line 28-60: The defaulting of options.globalVersion to an empty string
is redundant; update the assignment in getVersionMismatchWarning so
globalVersion is computed by calling normalizeVersion with options.globalVersion
(not options.globalVersion ?? ''), relying on normalizeVersion to handle
undefined/empty values; this simplifies the code while preserving behavior for
the normalizeVersion/globalVersion flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2399160f-0398-4420-8705-40983f828d2b
📥 Commits
Reviewing files that changed from the base of the PR and between d6d9fc9 and 084dd9c.
📒 Files selected for processing (4)
packages/cli/src/Generate.ts
packages/cli/src/__tests__/commands/Generate.test.ts
packages/cli/src/__tests__/version-mismatch-warning.test.ts
packages/cli/src/utils/version-mismatch-warning.ts
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Iineman2
commented
May 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
CLA is now signed, and CodeRabbit is clean after the follow-up simplification commit. Latest local targeted verification remains green:
pnpm --filter prisma test -- src/__tests__/version-mismatch-warning.test.ts
pnpm exec turbo build --filter=prisma
Happy to adjust quickly if maintainers prefer different wording or placement for the warning.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks — this is close: gating on isCurrentBinInstalledGlobally(), reading @prisma/client via getInstalledPrismaClientVersion() (node_modules first), and rejecting workspace:*/dist-tags/ranges in normalizeVersion() are all right.
One blocking ask: the prisma self-version side reads the package.json specifier (via getPackageJsonVersion/package-up) rather than the installed node_modules/prisma/package.json. normalizeVersion() mitigates the worst of it, but a ^7.0.0 specifier with a newer installed version still misreports. Please read the installed version for both packages, and get a full CI run on the branch (we saw the note about the Windows symlink issue blocking local verification).
We're triaging a large number of overlapping PRs for this issue. If we don't hear back within the next few days, we'll close this PR to keep the queue manageable.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jul 23, 2026
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|