GeezerVison is showing github.com — feat(cli): warn on global Prisma CLI vs local installed version mismatch by baronguyen001 · Pull Request #29578 · prisma/orm
Conversation
Summary
Adds a warning when prisma generate is invoked through a globally-installed Prisma CLI whose version differs from the prisma or @prisma/client actually installed in the project's node_modules. This is the situation described in #1911.
The warning is rendered through the existing post-generate hint pipeline (next to the existing client/CLI version-skew warning), so it doesn't change anything about how prisma generate is invoked, what files it produces, or how it behaves in scripts/CI — it just adds one extra advisory line when there's a mismatch.
How it differs from the other open attempts
I read PRs #29293, #29546, #29555, #29562 before starting. They each take a slightly different angle:
This PR instead reads the version field of the actually-installed local prisma/package.json and @prisma/client/package.json via require.resolve(..., { paths }). The check is gated by the existing isCurrentBinInstalledGlobally() helper from @prisma/internals, so we never warn when the CLI was run via npx / pnpm exec / yarn prisma / a workspace bin. The warning is non-blocking — generation still succeeds.
No new runtime dependency. The util reuses getInstalledPrismaClientVersion from ./utils/getClientVersion and only adds a sibling getInstalledPrismaCliVersion for the prisma package itself.
Changes
packages/cli/src/utils/checkGlobalLocalVersionMismatch.ts (new): pure function returning a warning string or null, with injectable dependencies for testing.
packages/cli/src/Generate.ts: call the util in the non-watch branch and append its output to the post-generate hint, alongside the existing versionsWarning for client/CLI skew.
packages/cli/src/__tests__/checkGlobalLocalVersionMismatch.test.ts (new): unit tests for the matrix of cases (not global, no local, exact match, prisma mismatch, client mismatch, both mismatch, only-one mismatch reported).
How tested
pnpm --filter prisma test src/__tests__/checkGlobalLocalVersionMismatch.test.ts → all 8 cases pass.
- Sanity-checked the warning string format manually.
- The util short-circuits to
null (no I/O) whenever the CLI isn't globally installed, so the existing prisma generate path is unaffected for the vast majority of users.
Notes for reviewers
- I deliberately kept the diff narrow — no package-manager detection, no
semver dependency, no confirm() prompt — because Warn on mismatch between global prisma and local prisma or @prisma/client #1911 only asks for a warning and any extra surface area becomes another thing to maintain.
- Happy to fold this into a shared util in
@prisma/internals if you'd prefer it available to other commands later; left it in packages/cli/src/utils for now to mirror getClientVersion.ts.
Resolves #1911
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
When the user runs a globally-installed prisma generate but the project has
a different version of prisma or @prisma/client in node_modules, emit a
non-blocking warning alongside the existing generate hint. The check is
gated by isCurrentBinInstalledGlobally so it's a no-op for local CLI
invocations.
Compares against the version field of the actually-installed package in
node_modules (not the specifier in package.json), so pinned/locked
mismatches are caught even when the manifest spec would match.
Resolves prisma#1911
|
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You have signed the CLA already but the status is still pending? Let us recheck it.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
May 22, 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: 7be16a62-e18d-47d2-89fe-e0286a9444b7
📥 Commits
Reviewing files that changed from the base of the PR and between a4cbb59 and bacea69.
📒 Files selected for processing (3)
packages/cli/src/Generate.ts
packages/cli/src/__tests__/checkGlobalLocalVersionMismatch.test.ts
packages/cli/src/utils/checkGlobalLocalVersionMismatch.ts
Summary by CodeRabbit
-
New Features
- CLI detects mismatches between a globally installed CLI and local Prisma /
@prisma/client versions and surfaces a clear, actionable warning during code generation.
- The generation output now includes the global/local version warning alongside existing hints, respecting hint suppression flags.
-
Tests
- Added tests validating detection, formatting, and display rules for global/local version mismatch warnings.
Walkthrough
Adds utilities to detect mismatches between a globally installed Prisma CLI and local prisma/@prisma/client, integrates the warning into the CLI's Generate command output, and adds Jest tests covering detection and formatting behavior.
Changes
Global and local Prisma version mismatch detection
| Layer / File(s) |
Summary |
Version mismatch utility module packages/cli/src/utils/checkGlobalLocalVersionMismatch.ts |
Exports types GlobalLocalVersionMismatch and CheckGlobalLocalVersionMismatchOptions, implements getGlobalLocalVersionMismatchWarning to detect and return warnings when local package versions differ from the global CLI version, formatGlobalLocalVersionMismatchWarning to build readable warning messages with remediation guidance, and getInstalledPrismaCliVersion to resolve local Prisma CLI versions from node_modules. |
Generate command integration packages/cli/src/Generate.ts |
Adds imports for version mismatch utilities, extends constructor to accept optional versionMismatchOptions, computes globalLocalVersionWarning at runtime when warnings are enabled, and includes the computed warning in hint text output alongside existing breaking-change and version-sync warnings. |
Test coverage packages/cli/src/__tests__/checkGlobalLocalVersionMismatch.test.ts |
Provides test suite validating getGlobalLocalVersionMismatchWarning returns null when no global install or local versions exist, returns warning messages when prisma and/or @prisma/client versions differ from global version, lists only mismatching packages in warnings, and validates formatGlobalLocalVersionMismatchWarning includes both versions and remediation instructions. |
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
⚠️ Warning |
Docstring coverage is 50.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 PR title accurately describes the main feature: warning users about version mismatches between globally-installed and locally-installed Prisma packages. |
| Description check |
✅ Passed |
The description comprehensively explains the changes, rationale, testing approach, and how this PR differs from previous attempts to address the issue. |
| Linked Issues check |
✅ Passed |
The implementation satisfies issue #1911 by detecting version mismatches between global and local Prisma/client packages and displaying a non-blocking warning [#1911]. |
| Out of Scope Changes check |
✅ Passed |
All changes are within scope: new utility module, integration into Generate.ts, and comprehensive test coverage for version mismatch detection. |
✏️ 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.
baronguyen001
changed the title
Fix #1911
feat(cli): warn on global Prisma CLI vs local installed version mismatch
May 22, 2026
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/checkGlobalLocalVersionMismatch.ts`:
- Around line 68-69: The formatter formatGlobalLocalVersionMismatchWarning
currently assumes mismatches[0] exists and will throw on an empty array; add a
guard at the start of formatGlobalLocalVersionMismatchWarning that checks
mismatches.length and returns a safe default (e.g., an empty string or a clear
"no mismatches" message) when the array is empty, otherwise proceed to read
mismatches[0].globalVersion and build the warning as before.
🪄 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: 596ddd02-3c50-443d-8313-b54b6a9d96dc
📥 Commits
Reviewing files that changed from the base of the PR and between 42f9102 and f64fe62.
📒 Files selected for processing (3)
packages/cli/src/Generate.ts
packages/cli/src/__tests__/checkGlobalLocalVersionMismatch.test.ts
packages/cli/src/utils/checkGlobalLocalVersionMismatch.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.
… input
The exported formatter dereferenced mismatches[0] without a length check,
so passing an empty array would throw instead of returning a warning.
Return an empty string up front when there is nothing to warn about.
|
Thanks — several things here are right: the gate on isCurrentBinInstalledGlobally(), reading the installed CLI version via require.resolve('prisma/package.json', ...), and loosening the hint gate so the warning also reaches projects that don't use the prisma-client-js generator.
Blocking:
- The
@prisma/client comparison reuses getInstalledPrismaClientVersion(), whose fallback reads the package.json specifier (e.g. ^7.5.0, workspace:*) — exactly the false-positive class to avoid, and at odds with the PR description's claim of comparing installed versions only. Please bypass that fallback (or read node_modules/@prisma/client/package.json directly) and skip the comparison when no installed version is found.
- The widened output branch for no-JS-client/errored generation has no test coverage — please add a case.
Also: please sign the CLA (link in the thread above); we can't merge without it.
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.
|
Hi @baronguyen001 — thanks for this, and apologies for the slow reply.
We're clearing the open PR backlog ahead of moving this codebase to a v7 branch, with the Prisma Next rewrite taking over main.
We are closing this one: the global/local version warning has already landed in #29593, with any remaining follow-up consolidated in #29546. Keeping another implementation open would duplicate that work.
Thanks for the time you put into it.
|
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
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.
|