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

Error with Prisma v15: can't find prisma.schema #824

Closed
CaptainChemist opened this issue Oct 22, 2019 · 46 comments
Closed

Error with Prisma v15: can't find prisma.schema #824

CaptainChemist opened this issue Oct 22, 2019 · 46 comments
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug.
Milestone

Comments

@CaptainChemist
Copy link

I updated to prisma version 15 and when I run prisma2 generate in a docker environment, I receive the error:

Error: Can't find prisma.schema

I don't see that the filename has been changed from schema.prisma to prisma.schema so this seems like a bug.

@janpio
Copy link
Member

janpio commented Oct 22, 2019

Can you tell us a bit more about the steps you took to create your project so we can try to reproduce this? Did you create a new project with prisma2 init or do you have an existing one?

@janpio
Copy link
Member

janpio commented Oct 22, 2019

Ok, so I can reproduce the wrongly worded error message when I create a new project with prisma2 init (Blank, SQLite, both, Demo), go into the project, rename the schema.prisma file and then run prisma2 generate:

C:\Users\Jan\Documents\throwaway\preview15  (script@1.0.0)
λ prisma2 generate
Error: Can't find prisma.schema

C:\Users\Jan\Documents\throwaway\preview15  (script@1.0.0)
λ ls prisma
dev.db  migrations/  schemdfa.prisma

@janpio janpio added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. labels Oct 22, 2019
@janpio
Copy link
Member

janpio commented Oct 22, 2019

@CaptainChemist So now the question is, should you actually be getting the error message? Do you have a prisma/schema.prisma file in your project?

@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. and removed bug/2-confirmed Bug has been reproduced and confirmed. labels Oct 22, 2019
timsuchanek added a commit that referenced this issue Oct 23, 2019
@timsuchanek
Copy link
Contributor

The latest alpha has a fix with the correct error message.
In case you indeed didn't have a schema.prisma file in your folder, we can close this.

@CaptainChemist
Copy link
Author

All I did was upgrade from version 13.2 where it was working and I had a schema.prisma file located in the prisma folder. It's funny though because today I cannot reproduce this issue, so I am not exactly sure what it is.

From what @timsuchanek is saying, the error message incorrectly was identifying the wrong file as missing, so perhaps my docker volumes were out of wack and even though my project had that file locally, perhaps it was missing in the docker container. I did notice that naming the file schema.prisma or prisma.schema didn't actually affect the error that I was receiving, so that does point to a docker/user related error. :)

In any case, I'll close this for now. Thanks everyone!

@ajmcclary
Copy link

I'm having the exact same issue. The error message states "prisma.schema" instead of "schema.prisma". I think that's just a typo.

But my installation can't find the schema.prisma file either when I use the following command (which is automatically run postinstall): cd libs/nest/api-photon && prisma2 generate

@ajmcclary
Copy link

Thought I'd mention, I installed the latest alpha and I still have the same issue as @CaptainChemist. The error message is fixed, but it still won't find the schema.prisma like it does in previous versions.

@ajmcclary
Copy link

@janpio, thought I'd share (since I'm having the same problem as @CaptainChemist), I did not start my project with prisma2 init. I started from an existing project. That might explain some things. I'm using an NX mono-repo. I'm guessing bet the path in the version 15 release changed?

@CaptainChemist
Copy link
Author

@ajmcclary Are you working in a dockerized or non-dockerized environment? Also you should try running prisma2 -v to make sure your global version is what you think it is since that could potentially switch around if you are using nvm or a similar node version manager.

@ajmcclary
Copy link

@CaptainChemist, I just figured it out. They introduced a new environmental variable:

process.env.INIT_CWD

So that is why it couldn't find it.

@ajmcclary
Copy link

Also, thank you for the suggestion. I'm non-dockerized, but I'm using an Nx repo. So my directory structure is different than a normal installation.

@ajmcclary
Copy link

OMG, @CaptainChemist, I did what you mentioned (just to be safe) and it WAS showing an older version of Prisma2! I swear and I double and triple checked it before I posted my comment. As soon as I rebooted, the new version finally showed up.

@CaptainChemist
Copy link
Author

Ha computers will be the death of us all- I'm glad you have it working better now!

@poulainv
Copy link

I am facing the same issue when I am trying to deploy on Now.
My dependencies:

{
    // ...
    "prisma2": "^2.0.0-preview015",
    "nexus": "^0.12.0-beta.14",
    "nexus-prisma": "^0.5.0",
}

My prisma2 version

prisma2 -v
prisma2@2.0.0-preview015, binary version: 20b6dc13949cccccfef5be07c0be7a3d7c858abe

I only get the error on Now during build

> script@ postinstall /zeit/56e0d573/api
--
02:53:48 PM | > yarn -s generate
02:53:50 PM | Error: Can't find prisma.schema

I was able to reproduce error many times. I did not create a new project from scratch, I updated an existing one.

@poulainv
Copy link

Note that my schema.prisma is located in api/prisma/schema.prisma
Locally I make it work setting INIT_CWD variable to api.
On Now I've tried to add

{
    "INIT_CWD": "api"
}

without success

@iherger
Copy link

iherger commented Oct 26, 2019

Same problem here (works locally, but can't deploy to Now [or Heroku, for that matter])

@poulainv
Copy link

Is your prisma directory located in a subdirectory as well?

@iherger
Copy link

iherger commented Oct 26, 2019

@poulainv , no, I am using the standard setup with schema.prisma located in the prisma directory.

@pantharshit00
Copy link
Contributor

Hi everyone,

We have recently merged a PR fixing this issue but it is not available in a preview yet: #789

Can you please test this out using the alpha channel. npm install -g prisma2@alpha

@iherger
Copy link

iherger commented Oct 28, 2019

My deployment to zeit now still fails.

Here's the build log:

Installing build runtime...
Build runtime installed: 3873.861ms
Looking up build cache...
Downloading user files...
download complete [0ms]
Installing dependencies...
missing `engines` in `package.json`, using default range: 8.10.x
Installing to /zeit/60a17008/src
yarn install v1.17.3
warning package.json: No license field
warning typescript-graphql: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "graphql-yoga > graphql-playground-middleware-lambda@1.7.12" has unmet peer dependency "aws-lambda@^0.1.2".
warning "graphql-yoga > graphql-subscriptions@0.5.8" has incorrect peer dependency "graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0".
warning "graphql-yoga > apollo-server-express > apollo-server-core@1.4.0" has incorrect peer dependency "graphql@^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0".
warning "graphql-yoga > apollo-server-express > apollo-server-core > apollo-cache-control@0.1.1" has incorrect peer dependency "graphql@0.10.x - 0.13.x".
warning "graphql-yoga > apollo-server-express > apollo-server-core > apollo-tracing@0.1.4" has incorrect peer dependency "graphql@0.10.x - 0.13.x".
warning "graphql-yoga > apollo-server-express > apollo-server-core > graphql-extensions@0.0.10" has incorrect peer dependency "graphql@0.10.x - 0.13.x".
[4/4] Building fresh packages...
$ prisma2 generate
Error: Can't find schema.prisma
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: Exited with 1
    at ChildProcess.child.on (/zeit/f07645855977bda8/.build-utils/.builder/node_modules/@now/node/dist/index.js:78330:24)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
worker exited with code 20 and signal null
done

Repo: https://github.com/iherger/prisma2-now

@aifedespaix
Copy link

@iherger I think zeit now prepare the container by installing only packages.
src files are copied after.

Try to remove the "postinstall" line from your package.json
And config your zeit now to run npm run generate post build.

(I got the same issue with my dockerfile)

@iherger
Copy link

iherger commented Oct 28, 2019

Thanks, @aifedespaix

I am hesitant to make the changes you suggest because a) the repo would deploy to zeit now without any problems before and b) the "official" prisma2 zeit now deployment example also uses postinstall, see: https://github.com/prisma/prisma-examples/blob/prisma2/deployment-platforms/zeit-now/api/package.json

@aputinski
Copy link

aputinski commented Oct 30, 2019

I'm having the same issue when deploying to Firebase functions. This was working fine in 2.0.0-preview-12. I'm using 2.0.0-alpha.276

@pantharshit00 pantharshit00 reopened this Oct 30, 2019
@iherger
Copy link

iherger commented Nov 4, 2019

@timsuchanek , I tested with another repo, but https://github.com/iherger/prisma2-now actually also doesn't work (I just upgraded package.json and redeployed).

@timsuchanek
Copy link
Contributor

@iherger I just tried your repo and I can successfully deploy it https://prisma2-now.timsuchanek.now.sh/

@iherger
Copy link

iherger commented Nov 4, 2019

@timsuchanek , nothing short of magic!

I can deploy it locally, using now dev but not remotely on zeit...

Are you also using a postgresql database?

@timsuchanek
Copy link
Contributor

Hmm interesting. I've kept the postgres env var empty, so it fails in runtime, but the error "Can't find prisma.schema" aka "Can't find schema.prisma" doesn't appear anymore.

@iherger
Copy link

iherger commented Nov 4, 2019

@timsuchanek so you are not using now secrets, if I unterstand you correctly, and everything elsr is the same as in the repo. Maybe it‘s got something to with those now secrets. I can test tomorrow, and will let you know my findings.

@poulainv
Copy link

poulainv commented Nov 5, 2019

On my side, this patch have fixed this issue

@pantharshit00
Copy link
Contributor

@iherger were you able to still reproduce this?

@iherger
Copy link

iherger commented Nov 6, 2019

@pantharshit00 , yes, I am still able to reproduce it.

What I found, though, is that it works if I use npm in my build script, and it will fail (with the error above) when I use yarn.

@pantharshit00
Copy link
Contributor

I am also able to deploy your repo and I am sure that zeit used yarn for this:
image

Also, try with preview 016 once.

@pantharshit00 pantharshit00 added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Nov 8, 2019
@iherger
Copy link

iherger commented Nov 8, 2019

@pantharshit00 , I can now longer reproduce this with preview016.

@timsuchanek
Copy link
Contributor

Perfect! Then I'll close this for now. In case you can reproduce it again, just let us know and we'll reopen.

@ephor
Copy link

ephor commented Dec 13, 2019

This error appears again in preview 18.2

@robabby
Copy link

robabby commented Dec 15, 2019

Also getting this in the latest alpha - 2.0.0-alpha.453

@pantharshit00
Copy link
Contributor

@robabby or @ephor Can you please open a new issue with a minimal reproduction? State whether you are getting it while development or when you are trying to deploy Prisma to something like now.

@robabby
Copy link

robabby commented Dec 19, 2019

@pantharshit00 I'll be back in this code over the weekend and see if I can still repro the issue on the latest versions that have been released this week and report back.

@AviBueno
Copy link

Prisma 2.2.1 with `prisma/schema.prisma' at the root of the project.

Trying to deploy to AWS Beanstalk, I get the following error:
Error: Either provide --schema or make sure that you are in a folder with a schema.prisma file.

It happens during this phase:

> @prisma/client@2.2.1 postinstall /var/app/staging/node_modules/@prisma/client
> node scripts/postinstall.js

Any ideas?

@pantharshit00
Copy link
Contributor

@AviBueno Please open a new issue with a minimal reproduction. Thanks!

@pantharshit00 pantharshit00 removed their assignment Jul 15, 2020
@binajmen
Copy link

binajmen commented Mar 14, 2021

I'm having the same issue when deploying to Firebase functions. This was working fine in 2.0.0-preview-12. I'm using 2.0.0-alpha.276

@aputinski Did you manage to solved it?

@miriam-may
Copy link

I'm having the same issue with Prisma 4.3.1 - when I run the command npx prisma migrate dev --name init I get could not find a schema.prisma file that is required for this command. I have the schema.prisma file in the default location (./prisma/schema.prisma). I tried adding the file path to my package.json as well just in case, but am getting the same error. Has there been any updates on this?

@janpio
Copy link
Member

janpio commented Sep 6, 2022

This is a closed issue, so there will be no more updates. If you still have this problem, please open a new issue and provide all the information the issue template asks for. Thanks.

@prisma prisma locked as resolved and limited conversation to collaborators Sep 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests