Environment variable not found
See original GitHub issueBug description
Since version 2.24.0
I got next error while making requests to my graphql server
"Error: Context creation failed: ",
"Invalid `prisma.user.findUnique()` invocation:",
" error: Environment variable not found: DATABASE_URL.",
" --> schema.prisma:3",
" | ",
" 2 | provider = \"postgresql\"",
" 3 | url = env(\"DATABASE_URL\")",
" | ",
Commands like prisma migrate
works correctly
I have next file structure
├── prisma
│ └── schema.prisma
├── src
│ └── server.ts
├── .env
In version 2.23.0
everything works as expected
How to reproduce
- Create graphql-server with
apollo-server
andprisma
- Add
PrismaClient
to context - Make graphql request
Expected behavior
No response
Prisma information
My schema.prisma
file starts like this
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["orderByRelation", "selectRelationCount"]
}
Environment & setup
- OS: Windows
- Database: PostgreSQL
- Node.js: 14.15.4
- apollo-server-express: 2.25.1
Prisma Version
2.24.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Problems with Environment Variables
Environment variable is not set. If the error message states that the environment variable is not set, IT MEANS PRECISELY THAT ! The...
Read more >Environment variables not found symfony - Stack Overflow
I've run into this problem myself. You have to explicitly map the environment variables you want to make accessible to php/symfony in ...
Read more >Environment variable not found since symfony 5.1 #126 - GitHub
Hello Since symfony 5.1 when running vendor / bin / behat there is an error message In EnvVarProcessor.php line 171: Environment variable not...
Read more >New Environment Variables Not Working in Windows 10
I am trying to put in paths to my php install and php composer. Here's what I got: C:\xampp\php\;. C:\xampp\htdocs\bill-dev-site\;.
Read more >Environment Variables > Symfony 6 Fundamentals
If you're not familiar with environment variables, they're variables that you can set on any system (Windows, Linux, whatever.)... and then you can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@janpio Yes, I use Yarn Workspaces in my project
I’m seeing the same issue beginning with version 2.24.0. In my case, it’s due to different behaviour leading up to
/sdk/utils/tryLoadEnvs
.v2.23.0:
config
value being passed togetPrismaClient
:Notice the
schemaEnvPath
being'C:\\Users\\gerr.it\\Desktop\\dev\\keystone-heroes\\packages\\@keystone-heroes\\db\\.env'
and debug statements being present.v2.24.0
config
value being passed togetPrismaClient
:Notice the line difference which in the code screenshot indicating the changes between the versions, although this function wasnt touched and how
schemaEnvPath
now is'C:\\Users\\gerr.it\\Desktop\\dev\\keystone-heroes\\node_modules\\.prisma\\client\\packages\\@keystone-heroes\\db\\.env'
.It’s late right now, I’ll try to whip up a repro tomorrow.
Edit: updated the config values. Apparently despite the name,
config.relativeEnvPaths
are no longer relative in 2.24.0.