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

Can't find the schema when the project path contains the same name as the generated client folder #11206

Closed
aqrln opened this issue Jan 17, 2022 · 1 comment · Fixed by #18910
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. tech/typescript Issue for tech TypeScript. topic: ENOENT schema.prisma Issues about "Error: ENOENT: no such file or directory, open '.../schema.prisma'" topic: output
Milestone

Comments

@aqrln
Copy link
Member

aqrln commented Jan 17, 2022

#9435 (comment) by @ykrop:

I had the same problem after upgrading too.
In my case seems to be caused by this code from index.js produced by Prisma npx generate:

// folder where the generated client is found
const dirname = findSync(process.cwd(), [
  "generated\\admin",
  "admin",
], ['d'], ['d'], 1)[0] || __dirname

As I have Prisma on a external folder and casually my project is in a path containing the same name given to generated scheme folder dirname var chose wrong path.

Schema output: project/prisma/generated/admin
Project: project/sites/admin/api

To solve it I just changed the generated prisma folder name.

Schema output: project/prisma/generated/adminSchema

Extracted from #9435 since it's a different bug than the one most people seem to be facing in the issue (and for which we have a fix in #10804), albeit both were uncovered at the same time by fixing another bug that used to mask these two in #9295.

@aqrln aqrln added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. tech/typescript Issue for tech TypeScript. team/client Issue for team Client. labels Jan 17, 2022
@janpio janpio added the topic: ENOENT schema.prisma Issues about "Error: ENOENT: no such file or directory, open '.../schema.prisma'" label Jan 28, 2023
@janpio
Copy link
Member

janpio commented Jan 28, 2023

Ok, to highlight the problem here as I did not instantly see it:

The problem is that both project/prisma/generated/admin (Schema output path) and project/sites/admin/api (project path) include admin which makes the schema finding logic match on the wrong folder.

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. tech/typescript Issue for tech TypeScript. topic: ENOENT schema.prisma Issues about "Error: ENOENT: no such file or directory, open '.../schema.prisma'" topic: output
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants