W
Waspβ€’4d ago
sib._.

no datasource in schema and schema.prisma empty in .wasp

hi, I've been trying to get wasp to compile with just fresh starter projects or the saas template. However, for the last three days I have been running into the same error and it's driving me insane! I have tried: different version of wasp, of node; fresh installs of wasp and running wasp new; sqlite and postgresql. I have used wasp before and deployed using fly.io especially using version 0.16.0 and wanted to check out 0.18.0 before doing a migration. once again after starting the db by running "wasp start db" it runs using postgresql next when I run "wasp db migrate-dev" or "wasp compile" I get the following output: any help is appreciated! """ 🐝 --- Compiling wasp project... -------------------------------------------------- βœ… --- Successfully completed npm install. ---------------------------------------- 🐝 --- Setting up database... ----------------------------------------------------- [ Db !] Error: There is no datasource in the schema. [ Db !] [ Db !] [ Db ] Environment variables loaded from .env [ Db ] Prisma schema loaded from ../db/schema.prisma [ Db !] Error: [ Db !] You don't have any datasource defined in your schema.prisma. [ Db !] You can define a datasource like this: [ Db !] [ Db !] datasource db { [ Db !] provider = "postgresql" [ Db !] url = env("DB_URL") [ Db !] } [ Db !] [ Db !] More information in our documentation: [ Db !] https://pris.ly/d/prisma-schema [ Db !] ❌ --- [Error] Your wasp project failed to compile: ------------------------------- - Prisma client generation failed with exit code: 1 ❌ --- [Error] Compilation of wasp project failed: -------------------------------- 1 errors found """
41 Replies
kapa.ai
kapa.aiβ€’4d ago
Hi @sib._.. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry you're running into this frustrating issue! Based on your error message:
[ Db !] Error: There is no datasource in the schema.
...
[ Db !] You don't have any datasource defined in your schema.prisma.
[ Db !] Error: There is no datasource in the schema.
...
[ Db !] You don't have any datasource defined in your schema.prisma.
This means that the generated schema.prisma file in your Wasp project's .wasp/out/db/ directory is empty or missing the datasource block. Normally, Wasp generates this file for you based on your main.wasp configuration and any defined entities. Possible causes and troubleshooting steps: 1. No Entities Defined in main.wasp:
If you don't have any entities defined in your main.wasp, Wasp may generate an empty or incomplete Prisma schema, leading to this error. Try adding at least one dummy entity to your main.wasp file, for example:
entity Dummy {=psl
id Int @id @default(autoincrement())
psl=}

entity Dummy {=psl
id Int @id @default(autoincrement())
psl=}

Then run wasp db migrate-dev again. This workaround has been suggested for similar issues in the past and can help the Prisma schema generation process proceed correctly Github Issue #398. 2. Corrupted or Incomplete Project State:
Sometimes, the build artifacts or generated files can get into a bad state. Try running:
wasp clean
wasp db migrate-dev

wasp clean
wasp db migrate-dev

This will clean out generated files and force Wasp to regenerate everything from scratch. This has resolved similar issues for other users Discord thread. 3. Check main.wasp for db Provider:
Ensure your main.wasp file includes a db block specifying the provider, e.g.:
db { provider: "postgres" }

db { provider: "postgres" }

If this is missing, Wasp may not generate the correct datasource in schema.prisma Github Issue #173. 4. Do Not Manually Edit schema.prisma:
You should not manually edit the generated schema.prisma file. Wasp manages this file based on your main.wasp configuration Discord thread. Summary:
- Add at least one entity to your main.wasp. - Make sure the db provider is set. - Run wasp clean and try again. If after these steps the problem persists, please share your main.wasp file (with sensitive info removed) and any additional error output. There may be a deeper issue, but these steps resolve the most common causes based on the knowledge sources. Let me know how it goes! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speechballoon: ---------------------- Sorry @sib.., I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
sib._.
sib._.OPβ€’4d ago
@kapa.ai still not working can you investigate '- Prisma client generation failed with exit code: 1'
kapa.ai
kapa.aiβ€’4d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the knowledge sources, the error message:
- Prisma client generation failed with exit code: 1
- Prisma client generation failed with exit code: 1
is typically caused by issues with the generated schema.prisma file, most often when it is missing a datasource block or is empty. This can happen if: - No entities are defined in your main.wasp file, which leads to Wasp generating an empty or incomplete Prisma schema. The workaround is to define at least one dummy entity in your main.wasp file and then run wasp db migrate-dev again. This has been confirmed as a fix in previous issues Github Issue #398. - The db block specifying the provider (e.g., postgres or sqlite) is missing from your main.wasp file, which prevents Wasp from generating the correct datasource in schema.prisma Github Issue #248. If you have already tried adding a dummy entity and ensured the db block is present, but the error persists, there may be a deeper issue with how Wasp is generating or handling the Prisma schema. The knowledge sources do not provide a definitive solution beyond these steps. Additionally, running wasp clean before trying again has resolved similar issues for other users, as it forces regeneration of all build artifacts and dependencies Discord support thread. If none of these steps resolve the issue, the knowledge sources do not contain enough information to provide a more specific solution. In that case, sharing your main.wasp file and the full error output with the Wasp community or opening a GitHub issue may help identify the root cause. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speechballoon: ---------------------- Sorry @sib.., I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
genyus
genyusβ€’4d ago
@sib._. Can you share your prisma.schema file?
sib._.
sib._.OPβ€’4d ago
here @genyus generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id Int @id @default(autoincrement()) tasks Task[] } model Task { id Int @id @default(autoincrement()) description String isDone Boolean @default(false) user User @relation(fields: [userId], references: [id]) userId Int } sorry for the late reply was cooking @kapa.ai I've tried this and it does not work at all still
kapa.ai
kapa.aiβ€’4d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I'm sorry to hear that the previous steps did not resolve your issue. Based on the knowledge sources, the error:
- Prisma client generation failed with exit code: 1
- Prisma client generation failed with exit code: 1
is most commonly linked to problems with the generated schema.prisma fileβ€”specifically, it being empty or missing a datasource block. This typically happens if there are no entities defined in your main.wasp file, or if the db block is missing or misconfigured. Adding a dummy entity and ensuring the db block is present are the main recommended solutions, and running wasp clean has helped some users in similar situations. However, since you have already tried these steps and the problem persists, I must state that the knowledge sources do not contain enough information to provide a more specific or advanced solution for your case. There is no documented fix beyond what has already been suggested, and no deeper troubleshooting steps are available in the provided sources. If you are still encountering this error after following all the recommended steps, the best course of action would be to share your main.wasp file and the full error output with the Wasp community or to open a GitHub issue, as your situation may require direct investigation by the maintainers or more context-specific troubleshooting. I'm sorry I can't provide a more definitive answer based on the current knowledge sources. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speechballoon: ---------------------- Sorry @sib.., I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
genyus
genyusβ€’4d ago
The file looks fine. Can you run wasp clean and then compile again. If you get the same error, please share your .wasp/out/db/schema.prima file
sib._.
sib._.OPβ€’4d ago
it's there but empty
MEE6
MEE6β€’4d ago
Wohooo @sib._., you just became a Waspeteer level 1!
sib._.
sib._.OPβ€’4d ago
the schema.prisma file is present in the folder .wasp/out/db/ however there is nothing inside of it, it is just blank
genyus
genyusβ€’4d ago
Well, that explains the error, although the question is why it's not being populated. Could you run wasp compile > log.txt 2>&1 and then share the log.txt file here, please? Also, you said you've been trying different Node versions, what is the current?
sib._.
sib._.OPβ€’4d ago
[ Db !] Error: There is no datasource in the schema. [ Db !] [ Db !]  🐝 --- Compiling wasp project... --------------------------------------------------   βœ… --- Successfully completed npm install. ----------------------------------------   🐝 --- Setting up database... -----------------------------------------------------  [ Db ] Environment variables loaded from .env [ Db ] Prisma schema loaded from ../db/schema.prisma [ Db !] Error: [ Db !] You don't have any datasource defined in your schema.prisma. [ Db !] You can define a datasource like this: [ Db !] [ Db !] datasource db { [ Db !] provider = "postgresql" [ Db !] url = env("DB_URL") [ Db !] } [ Db !] [ Db !] More information in our documentation: [ Db !] https://pris.ly/d/prisma-schema [ Db !]  ❌ --- [Error] Your wasp project failed to compile: ------------------------------- - Prisma client generation failed with exit code: 1  πŸ‘€ --- [Warning] Your wasp project reported following warnings during compilation: --- - Wasp was unable to verify your database is up to date. Running wasp db migrate-dev may fix this and will provide more info.  ❌ --- [Error] Compilation of wasp project failed: -------------------------------- 1 errors found right now I'm using node 22.20.0
sib._.
sib._.OPβ€’4d ago
here is the file
genyus
genyusβ€’4d ago
Does this error only occur with your 0.18 instance? Or you're having the problem with all your local Wasp projects?
sib._.
sib._.OPβ€’3d ago
i've tried 0.16.0, 0.17.0, 0.18.0 .... the problem indeed persists with all local wasp projects it's always the same error for various projects @genyus any ideas would be appreciated!
miho
mihoβ€’3d ago
If you can, please share your schema.prisma file here, I suspect it's something with our Prisma parser
sib._.
sib._.OPβ€’3d ago
here you go, this is a small one (I made for checking if changing wasp versions would fix the error, it didn't...)
sib._.
sib._.OPβ€’3d ago
I have also tried the default schema.prisma that is generated when doing wasp new MyApp and I have also tried compiling with the schema.prisma from the saas template, all of which with no success..
miho
mihoβ€’3d ago
Can you try doing this:
wasp new test
cd test
wasp db migrate-dev
wasp new test
cd test
wasp db migrate-dev
Does that work for you?
sib._.
sib._.OPβ€’3d ago
I have tried this. I stil lget the exact same error "Error: There is no datasource in the schema."
MEE6
MEE6β€’3d ago
Wohooo @sib._., you just became a Waspeteer level 2!
miho
mihoβ€’3d ago
Please run it again so I can see the full output πŸ™‚
sib._.
sib._.OPβ€’3d ago
here is the output
miho
mihoβ€’3d ago
curl -sSL https://get.wasp.sh/installer.sh | sh -s
wasp new test
cd test
wasp db migrate-dev
curl -sSL https://get.wasp.sh/installer.sh | sh -s
wasp new test
cd test
wasp db migrate-dev
Run this - let's see what happens when you do it from scratch
sib._.
sib._.OPβ€’3d ago
this will auto install wasp 18 right?
miho
mihoβ€’3d ago
Yep The version doesn't matter that much, but I wanted to see it as from-scratch as possible
sib._.
sib._.OPβ€’3d ago
literally the same error again.
miho
mihoβ€’3d ago
Please copy the full output, here's mine for example:
sib._.
sib._.OPβ€’3d ago
Here you go.
miho
mihoβ€’3d ago
That's pretty wild πŸ˜„ I've never seen this fail like this. What is your Node.js and npm version?
sib._.
sib._.OPβ€’3d ago
simon@zen:~/test$ node -v v22.20.0 simon@zen:~/test$ npm -v 10.9.3
miho
mihoβ€’3d ago
Also pls share from the test project:
cat .wasp/out/db/schema.prisma
cat node_modules/.prisma/client/schema.prisma
cat .wasp/out/db/schema.prisma
cat node_modules/.prisma/client/schema.prisma
sib._.
sib._.OPβ€’3d ago
the schema.prisma is there but completely empty. in the wasp out db bin simon@zen:~/dev/test$ cat .wasp/out/db/schema.prisma simon@zen:~/dev/test$ cat node_modules/.prisma/client/schema.prisma cat: node_modules/.prisma/client/schema.prisma: No such file or directory
miho
mihoβ€’3d ago
I guess another question for you, what is your OS? Mac, Linux, WSL2? Is your setup specific for some reason? πŸ™‚
sib._.
sib._.OPβ€’3d ago
Running Ubuntu 24.04 LTS It's just the stock OS installed nvm, node and wasp are all installed using apt-get wasp 0.16 was working fine on the same OS in February, I will try to run a fresh wasp project using an old laptop probably later today to see if maybe it's an OS dependent issue (long shot but still)
miho
mihoβ€’3d ago
Ok, thank you for trying to figure it out with me!
sib._.
sib._.OPβ€’2d ago
any idea what is going wrong on my system?
miho
mihoβ€’2d ago
Did you do this:
I will try to run a fresh wasp project using an old laptop probably later today to see if maybe it's an OS dependent issue (long shot but still)
I'm not really sure what can go wrong, that's why I keep asking you to run things πŸ™‚ for me - it works perfectly on my Mac and on my Ubuntu 22 server
sib._.
sib._.OPβ€’2d ago
no not yet, i just want it to run on this system, my fast larger lighter laptop..
miho
mihoβ€’this hour
@sodic do you mind picking this one up? I couldn't figure it out - maybe you'll have some fresh idea how to debug this?
sib._.
sib._.OPβ€’23h ago
Any help would be appreciated as I am hard stuck on things to try

Did you find this page helpful?