docs icon indicating copy to clipboard operation
docs copied to clipboard

Generator: `output` is relative to `./prisma`

Open janpio opened this issue 4 years ago • 8 comments

If you have a generator in your schema.prisma like this:

generator testutils {
  provider = "./node_modules/prisma-test-utils/dist/generator.js"
  output = "./node_modules/@generated/prisma-test-utils"
}

The output is actually generated in ./prisma/node_modules/@generated/prisma-test-utils:

✔ Generated Prisma Test Utils to .\prisma\node_modules\@generated\prisma-test-utils in 3.95s

That was unexpected to me.

Changing output to use ../node_modules... fixes the problem.

(Could potentially also be the fault of the generator I am trying to use.)

janpio avatar Mar 01 '20 22:03 janpio

Same with url when using local file sqlite db.

# prisma/schema.prisma
datasource db {
  provider = "sqlite"
  # need to escape prisma dir to have it in "temp/dev.db"
  url      = "file:../temp/dev.db"
}

I would expect it to be cwd/project root relative - now I need kind of special config field for prisma file relative path.

Imho It's not that big of an issue, but I think it's the right time to fix it since later it would be a very braking change.

Very random btw - wow, github supports your syntax highlighting!! :+1:

vadistic avatar Apr 01 '20 00:04 vadistic

@vadistic Can you please open a new github issue about this? I think for sqlite path, this is expected behaviour but we can discuss that in a new issue while not adding irrelevant information to this issue.

pantharshit00 avatar Apr 01 '20 15:04 pantharshit00

@pantharshit00 Sure - I just thought it's the same thing that could be formulated like "relative paths in .prisma file are relative to prisma, not project root ". Both behaviors are ok, but imho should be uniform.

https://github.com/prisma/prisma/issues/2040

vadistic avatar Apr 01 '20 15:04 vadistic

This needs to be confirmed with a current version again please @pantharshit00.

janpio avatar Sep 02 '20 03:09 janpio

This still happens in 2.6.0-dev.61. The output still uses the prisma directory as a root.

image

pantharshit00 avatar Sep 02 '20 11:09 pantharshit00

We still treat prisma as root directory in 2.21.2. I guess we should close this now as fixing this now will break thing for folks.

pantharshit00 avatar May 04 '21 14:05 pantharshit00

If this is relative to the schema file, this is also technically correct. I wonder if we document it somewhere differently (or not at all, and adding the "relative to your schema.primsa file where you define the generator could help a lot), or if indeed this can be different per generator.

janpio avatar May 04 '21 17:05 janpio

Ok, it is indeed relative to schema.prisma location. I just tried that out.

We don't document whether it is relative to schema or not: https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#fields-1

pantharshit00 avatar May 05 '21 12:05 pantharshit00