BA
Better Authโ€ข3mo ago
Duki

npx @better-auth/cli generate logs weird stuff on the console when run and fails

I just upgrade to 1.3.3 and for good measure I wanted to execute the cli comman generate and noticed that is logging some code in the terminal (added a screenshot, because it's too much text) and throws a prisma error at me. The error makes no sense to me. It says the URL must start with "file:", but the url actually does start with file: and the error logs are even showing the line where file: is set ๐Ÿคจ Has anyone else encountered this issue?
PrismaClientInitializationError: error: Error validating datasource `db`: the URL must start with the protocol `file:`.
--> schema.prisma:14
|
13 | provider = "sqlite"
14 | url = "file:./data.db"
|

Validation Error Count: 1
at r (/Users/duki/IdeaProjects/simple-recipe-app/node_modules/@prisma-app/client/runtime/library.js:115:2770) {
clientVersion: '6.12.0',
errorCode: 'P1012',
retryable: undefined
}
PrismaClientInitializationError: error: Error validating datasource `db`: the URL must start with the protocol `file:`.
--> schema.prisma:14
|
13 | provider = "sqlite"
14 | url = "file:./data.db"
|

Validation Error Count: 1
at r (/Users/duki/IdeaProjects/simple-recipe-app/node_modules/@prisma-app/client/runtime/library.js:115:2770) {
clientVersion: '6.12.0',
errorCode: 'P1012',
retryable: undefined
}
No description
Solution:
AH! Found the issue! I had to add dotenvx run -f .env -- in front of the generate command. ๐Ÿคฆโ€โ™‚๏ธ
Jump to solution
6 Replies
Ping
Pingโ€ข3mo ago
@Duki try using file:// Also i dont know if using the file protocol supports relative paths, but I guess we will find out lol
Duki
DukiOPโ€ข3mo ago
I'm still getting the same error. When I run prisma generate myself it runs through without any error. It only happens when using BA's generate. It has worked before tho ๐Ÿค” Also doesnt work without a relative path "file://dev.db"
Solution
Duki
Dukiโ€ข3mo ago
AH! Found the issue! I had to add dotenvx run -f .env -- in front of the generate command. ๐Ÿคฆโ€โ™‚๏ธ
Duki
DukiOPโ€ข3mo ago
because initially I had this in my schema.prisma file:
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
I changed it to a hardcoded value, because I thought it would be easier that way, but apparently BA doesn't use the same prisma client as the one generated via prisma generate and somehow still had the version with the env("DATABASE_URL") in it, instead of the hard coded one ๐Ÿค” Which is weird, because the error that it logs are coming from the newly generated schema.prisma file. I am very confused right now ๐Ÿ˜‚ Which schema.prisma does BA use during the generating process?
Ping
Pingโ€ข3mo ago
wdym? We generate based on the auth config
Duki
DukiOPโ€ข3mo ago
nvm I mixed things up during the initialisation of the prisma client. All clear now! Conside this issue as resolve ๐Ÿ™ˆ thanks a lot for your help!

Did you find this page helpful?