-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
npm run dev
fails in new t3-app due to missing DATABASE_URL
#204
Comments
Works after renaming What if the last step of the CLI asked you to enter values for the whatever |
The reason it fails is you need a .env file as Adam pointed out. We could maybe rename the .env-example to .env and that way it would start out of the box? Fwiw, This is what we do in our CI to get a working build in there. |
That seems like a reasonable solution. Requiring a db url string despite sqlite not actually using it still isn't ideal, but I also can't think of a better solution so maybe this is a good way to go for now. |
IMHO the scaffolded project should be able to run in dev mode just after it's creation, so +1 in having the Also I haven't really used prisma, but could it be possible for the initial Note that this would also serve as an example to users that they should NOT hardcode the database url in the Examples: // schema.prisma
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
} // .env
# Prisma
DATABASE_URL="file:./db.sqlite" # <- if changing provider, remember to update `/prisma/schema.prisma` |
Not sure if // schema.prisma
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
} # .env-example
# Prisma
DATABASE_URL=file:./db.sqlite // installers/envVars.ts
await Promise.all([
fs.copy(envSchemaSrc, envSchemaDest, { overwrite: true }),
fs.rename(envExample, envDest),
]); EDIT: @ochicf beat me to it ;) |
I like this a lot. If it doesn't pass the zod check, we could add |
I'm not proficient with zod, but could it be a more relaxed check to allow strings starting with Not sure if this would have some side effects (ex: if the file is gitignored) |
Just checked and seems to validate just fine. |
I can implement this, but would probably wait until I see what happens with #205 to avoid a potential merge conflict |
fixed with #222 |
Describe the bug
npm run dev
fails in a new t3-app because it's missing the DATABASE_URL environment variable. However the default database is sqlite, which doesn't need that environment variable.To Reproduce
Steps to reproduce the behavior:
yarn dev
Expected behavior
Not sure! Maybe this is ok because we assume that anyone who uses Prisma will want to switch away from sqlite and thus needs a database url? However I don't think it's a great experience - the first thing I want to do after initializing an app is start the dev server and check that everything installed fine, which this prevents.
Would be happy to hear what others think the expected behavior should be.
Screenshots
The text was updated successfully, but these errors were encountered: