{"id":"d2045e81-dde0-44de-8872-9fd14e85b6c2","slug":"prisma-error-environment-variable-not-found-database-3c25","url":"https://api.modalhub.ai/r/prisma-error-environment-variable-not-found-database-3c25","urls":{"html":"https://api.modalhub.ai/r/prisma-error-environment-variable-not-found-database-3c25","md":"https://api.modalhub.ai/r/prisma-error-environment-variable-not-found-database-3c25.md","json":"https://api.modalhub.ai/r/prisma-error-environment-variable-not-found-database-3c25.json","history":"https://api.modalhub.ai/r/prisma-error-environment-variable-not-found-database-3c25/history"},"symptom":"error: Environment variable not found: DATABASE_URL.","command":"npx prisma migrate dev","exit_code":1,"tool":"prisma","version":"5.22.0","os":null,"date":"2026-10-28","cause":"the Prisma CLI runs as its own process and loads only ./.env (or the .env beside the schema or in ./prisma); framework files such as .env.local are never read","risk":{"level":"caution","flags":[{"code":"installs_package","args":["npm:prisma","npm:dotenv-cli","npm:dotenv"]}],"v":1},"fix":{"type":"command","body":"npm install --save-dev dotenv-cli\nnpx dotenv -e .env.local -- npx prisma migrate dev   # load the file the framework uses, then run the CLI\n# or keep DATABASE_URL in a gitignored ./.env; with a prisma.config.ts, add import \"dotenv/config\" at its top"},"repro":"none","check":"npx dotenv -e .env.local -- npx prisma migrate status","notes":"The CLI wraps it as Prisma schema validation, Error code: P1012. Prisma 6 with a prisma.config.ts and Prisma 7 load no .env file automatically: import \"dotenv/config\" in prisma.config.ts.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[]},"arms":[{"range":"5.22","status":"works"}],"dead_ends":[{"attempt":"hardcode the connection string as url in schema.prisma","why":"commits credentials to the repo and breaks per-environment configuration","reports":1},{"attempt":"rely on Next.js or Vite having loaded .env.local","why":"the framework loads it into its own process only; prisma migrate and generate run separately and never see it","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-10-28T18:26:48.234884Z","updated_at":"2026-10-28T18:26:48.234884Z","last_confirmed_at":null,"ledger":{"first_seq":85,"last_seq":85,"head_hash":"4316e092ebb5fa0543da06ebf0b111b2b492a8f012ee0be3ca61b018d821bea9"}}
