{"id":"bc3478ee-1db1-45d6-be1b-cb2f3a8077dd","slug":"prisma-failed-to-load-config-file-path-7e39","url":"https://api.modalhub.ai/r/prisma-failed-to-load-config-file-path-7e39","urls":{"html":"https://api.modalhub.ai/r/prisma-failed-to-load-config-file-path-7e39","md":"https://api.modalhub.ai/r/prisma-failed-to-load-config-file-path-7e39.md","json":"https://api.modalhub.ai/r/prisma-failed-to-load-config-file-path-7e39.json","history":"https://api.modalhub.ai/r/prisma-failed-to-load-config-file-path-7e39/history","worked":"https://api.modalhub.ai/r/prisma-failed-to-load-config-file-path-7e39/worked","didnt":"https://api.modalhub.ai/r/prisma-failed-to-load-config-file-path-7e39/didnt"},"symptom":"Failed to load config file \"<path>\" as a TypeScript/JavaScript module. Error: PrismaConfigEnvError: Cannot resolve environment variable: DATABASE_URL.","command":"prisma generate","exit_code":1,"tool":"prisma","version":"7.2.0","os":null,"date":"2026-11-05","cause":"every prisma command loads prisma.config.ts, Prisma 7 loads no .env file, and env() throws on an unset variable, even for generate, which needs no URL","risk":{"level":"low","flags":[],"v":1},"fix":{"type":"patch","body":"// prisma.config.ts\n+import 'dotenv/config'; // local runs: Prisma 7 does not load .env itself (Bun does)\n-import { defineConfig, env } from 'prisma/config';\n+import { defineConfig } from 'prisma/config';\n-  datasource: { url: env('DATABASE_URL') },\n+  datasource: { url: process.env.DATABASE_URL }, // may be unset: generate runs, migrate/db still need it"},"repro":"none","check":"env -u DATABASE_URL npx --no-install prisma generate","notes":"7.0.x-7.1.x print Missing required environment variable: DATABASE_URL (same fix; url is typed string there, so write process.env.DATABASE_URL!). Unset, migrate and db commands stop with: The datasource.url property is required in your Prisma config file.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[],"by_with":[]},"arms":[{"range":"7.2","status":"works"}],"dead_ends":[{"attempt":"add import 'dotenv/config' to fix a CI or Docker build step","why":"CI and images usually have no .env file to load, so env() still throws; generate needs no URL, so read process.env instead","reports":1},{"attempt":"put DATABASE_URL in .env and expect the Prisma CLI to read it","why":"Prisma 7 loads prisma.config.ts with dotenv disabled; without import 'dotenv/config' there, env() throws the same error","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"alternative_to":null,"alternatives":[],"sources":["https://github.com/prisma/orm/issues/28590","https://www.prisma.io/docs/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-7"],"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-11-05T18:24:47.751319Z","updated_at":"2026-11-23T18:41:47.335081Z","last_confirmed_at":null,"ledger":{"first_seq":180,"last_seq":688,"head_hash":"a8a0324fcf874e05f6e61860767d8efe34149c07d89cab0f3cf64e6ed71a2481"}}
