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

npx prisma@{version} generate does not pass the given version to generators when prisma is installed in the working directory #10573

Closed
RobertCraigie opened this issue Dec 4, 2021 · 5 comments
Assignees
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: prisma generate CLI: prisma generate

Comments

@RobertCraigie
Copy link

RobertCraigie commented Dec 4, 2021

Bug description

If you explicitly pass the version to npx, e.g. npx prisma@3.4.0 generate while already having the CLI installed in the current directory, e.g.

npm install prisma@3.6.0
npx prisma@3.4.0 generate # version @3.6.0 is passed to generators

How to reproduce

https://github.com/RobertCraigie/prisma-npx-version-reproduction

Expected behavior

The generator should be given the 3.4.0 version

Prisma information

See reproduction.

Environment & setup

  • OS: Mac OS
  • Database: N/A
  • Node.js version: v17.1.0

Prisma Version

prisma                  : 3.6.0
@prisma/client          : Not found
Current platform        : darwin
Query Engine (Node-API) : libquery-engine dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at ../../../.npm/_npx/2778af9cee32ff87/node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at ../../../.npm/_npx/2778af9cee32ff87/node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at ../../../.npm/_npx/2778af9cee32ff87/node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at ../../../.npm/_npx/2778af9cee32ff87/node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : dc520b92b1ebb2d28dc3161f9f82e875bd35d727
Studio                  : 0.440.0
@RobertCraigie RobertCraigie added the kind/bug A reported bug. label Dec 4, 2021
@janpio janpio added topic: prisma generate CLI: prisma generate bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/client Issue for team Client. labels Dec 4, 2021
@janpio
Copy link
Member

janpio commented Dec 4, 2021

That is an interesting observation and points to a fundamental problem in how we retrieve the version of prisma that is running.

@jkomyno
Copy link
Contributor

jkomyno commented Sep 28, 2022

Hi, while this issue is in fact reproducible with prisma@3.6.0, it doesn't seem to arise with the latest versions of prisma@4.x.x.

Reproduction

System info: darwin, Node.js 18.8.0, npx@8.18.0, no prisma executable installed globally.

Considering the reproduction repo, drop package-lock.json and bump @prisma/generator-helper to ^4.2.0, replacing the package.json file with:

{
  "name": "prisma-npx-version-reproduction",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "generator": "ts-node src"
  },
  "dependencies": {
    "@prisma/generator-helper": "^4.2.0",
    "ts-node": "^10.4.0"
  }
}

Run the following commands:

❯ npx prisma@4.3.0 generate
Got prisma version c875e43600dfe042452e0b868f7a48b817b9640b
npm install prisma@4.4.0
❯ npx prisma@4.3.0 generate
Got prisma version c875e43600dfe042452e0b868f7a48b817b9640b

As we can see, the two prisma version's hashes are the same.

@jkomyno jkomyno self-assigned this Sep 28, 2022
@janpio
Copy link
Member

janpio commented Sep 28, 2022

I think this might indeed rely on the npm/npx version being used. If I am reading this correctly, it might have been related to npm/cli#3210 (which was a big source for confusion in the past).

@aqrln
Copy link
Member

aqrln commented May 12, 2023

Given the previous two comments, should this issue be closed?

@aqrln
Copy link
Member

aqrln commented May 15, 2023

Confirmed that it was a bug in npm and not in Prisma with the reproduction repo: the hash is now identical (1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85) when running npx prisma@3.4.0 generate both before and after installing prisma@3.6.0 locally. So Prisma passed its version to the generator correctly, it was npx that ran completely different version of Prisma than was requested, which is something I don't think we could detect or work around.

Given the above, and since none of the Node.js versions we currently officially support seem to ship with affected npm 7 (docker run node:14 npm --version prints 6.14.18 and docker run node:16 npm --version prints 8.19.4), I'll go ahead and close this issue. Please let me know if I missed something.

@aqrln aqrln closed this as completed May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: prisma generate CLI: prisma generate
Projects
None yet
Development

No branches or pull requests

4 participants