-
Notifications
You must be signed in to change notification settings - Fork 2.1k
importing prisma client pollutes process.env without using dotenv #19519
Copy link
Copy link
Closed
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.topic: .envtopic: breaking changetopic: envtopic: environmenttopic: prisma-client
Milestone
Description
Bug description
If you put MY_TEST_VAR in a .env file and import a prisma client, then process.env.MY_TEST_VAR will be defined, despite the fact that we are not using e.g. dotenv.
How to reproduce
prisma/schema.prisma:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL_MAIN")
}
model Locations {
LocationID Int @id
LocationName String @db.VarChar(45)
}
package.json:
{
"type": "module",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"@prisma/client": "^4.14.1",
"prisma": "^4.14.1"
}
}.env:
MY_TEST_VAR="THIS IS THE VALUE OF MY_TEST_VAR"app.js:
import { PrismaClient } from '@prisma/client'
console.log(process.env.MY_TEST_VAR);npx prisma generate
npm start
(logs the variable, not undefined)
Expected behavior
The expected behaviour is that undefined is logged
So what is said here is a bit misleading, because the variables will be loaded anyway
"If you want environment variables to be evaluated at runtime, you need to load them manually in your application code (for example, by using dotenv)"
Prisma information
(same as above)
prisma/schema.prisma:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL_MAIN")
}
model Locations {
LocationID Int @id
LocationName String @db.VarChar(45)
}
Environment & setup
Mac and linux
Prisma Version
prisma : 4.15.0
@prisma/client : 4.15.0
Current platform : darwin-arm64
Query Engine (Node-API) : libquery-engine 8fbc245156db7124f997f4cecdd8d1219e360944 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine : migration-engine-cli 8fbc245156db7124f997f4cecdd8d1219e360944 (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Format Wasm : @prisma/prisma-fmt-wasm 4.15.0-28.8fbc245156db7124f997f4cecdd8d1219e360944
Default Engines Hash : 8fbc245156db7124f997f4cecdd8d1219e360944
Studio : 0.484.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.topic: .envtopic: breaking changetopic: envtopic: environmenttopic: prisma-client