Prisma · tool · fg-0291

prisma generate fails in CI or Docker builds with 'PrismaConfigEnvError: Cannot resolve environment variable: DATABASE_URL'

If you see Error: PrismaConfigEnvError: Cannot resolve environment variable: DATABASE_URL, the cause and the fix for Prisma are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Error: PrismaConfigEnvError: Cannot resolve environment variable: DATABASE_URL.Error: PrismaConfigEnvError: Missing required environment variable: DATABASE_URLA typecheck-only CI job that never touches the database now needs a database URL
Cause
Prisma 7 loads prisma.config.ts for every CLI command, and env() from prisma/config throws when the variable is unset, even for generate. Prisma 7 also stopped reading the env file automatically, so the config has to load dotenv itself.
Fix
Import dotenv/config at the top of the config and read process.env directly, so generate runs without a URL while migrate commands still fail with a clear message.
Apply
import 'dotenv/config' import { defineConfig } from 'prisma/config' export default defineConfig({ schema: 'prisma/schema.prisma', migrations: { path: 'prisma/migrations' }, datasource: { url: process.env.DATABASE_URL }, })
Affected
Prisma ORM 7.0 and later; the process.env form is accepted by 7.8.0 and later and was verified on 7.10.0
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun