(Re)Introspection does not respect variables in dotenv file when schema is located in a custom directory
See original GitHub issueBug description
When the schema file is located in a custom directory, the dotenv file located in the same directory as the schema file, is not read by the Prisma CLI.
How to reproduce
Assuming we have the following project structure,
- test-prisma-dotenv
- db
- .env
- schema.prisma
- node_modules
- package.json
- yarn.lock
- db
Then run the following command to re-introspect in the project root directory
yarn prisma introspect --schema db/schema.prisma --experimental-reintrospection
Results in such error
Introspecting based on datasource defined in db/schema.prisma …
Error: Error in datamodel: ErrorCollection { errors: [EnvironmentFunctionalEvaluationError { var_name: "DATABASE_URL", span: Span { start: 160, end: 179 } }] }
However, if we run the command without the --experimental-reintrospection
, it works as expected that the Prisma CLI respects the environment variable in the dotenv file.
Expected behavior
Prisma information
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
Environment & setup
- OS:
- Database:
- Prisma version:
- Node.js version:
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Managing .env files and setting variables - Prisma
Learn how to manage .env files and set environment variables.
Read more >dotenv file is not loading environment variables - Stack Overflow
in my case i am compiling ts in dist folder and env files are not located in dist folder, but in the root...
Read more >Building a schema | Full-Stack Quickstart - Apollo GraphQL
Your GraphQL schema defines what types of data a client can read and write to your graph. Schemas are strongly typed, which unlocks...
Read more >Environment variables | dbt Developer Hub
Use environment variables to customize the behavior of your dbt project. ... Environment variables keys are uppercased and case sensitive.
Read more >Configuration Options | Directus Docs
Environment variables are used for all configuration within a Directus ... If the config path has no file extension, or a file extension ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please create a new issue @mjknight50 and supply some more information - best fill the issue template.
@timsuchanek This same error happened for me today.
ErrorCollection { errors: [EnvironmentFunctionalEvaluationError { var_name: "DATABASE_URL"
“@prisma/cli”: “^2.8.0”, “@prisma/client”: “^2.6.2”,
My schema is:
The path is irregular: /server/data/prisma/schema.prisma