Skip to content

"Environment variables loaded from .env" is misleading #10104

@bennycode

Description

@bennycode

Bug description

I followed the "Running migrations on different environments" guide and executed this statement in my terminal:

dotenv -e .env.test -- npx prisma migrate dev

It was giving me the following output:

Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": PostgreSQL database "tests", schema "public" at "localhost:5433"

I was very surprised because I do have a .env and .env.test file in my project and thought that Pisma is not pickung up my .env.test file because it's reporting that it loaded variables from ".env". In fact it used my .env.test file.

How to reproduce

  1. Create a .env file with DATABASE_URL="postgresql://postgres:postgres@localhost:5432/root_db?schema=public"
  2. Create a .env.test file with DATABASE_URL="postgresql://prisma:prisma@localhost:5433/test_db?schema=public"
  3. Run dotenv -e .env.test -- npx prisma migrate dev

Expected behavior

To avoid this confusion I suggest to change the phrasing of the console output. Preferably it should show the correct file name (e.g. loaded from .env.test) or not mention the file name at all (e.g. loaded environment variables).

Prisma information

schema.prisma

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model enum_role {
    type        String @id
    description String
}

Environment & setup

  • OS: Windows 10
  • Database: PostgreSQL
  • Node.js version: 16.10.0

Prisma Version

prisma                  : 3.4.0
@prisma/client          : 3.4.0
Current platform        : windows
Query Engine (Node-API) : libquery-engine 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at ..\..\node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at ..\..\node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine    : introspection-core 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at ..\..\node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary           : prisma-fmt 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at ..\..\node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash    : 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85
Studio                  : 0.438.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions