Skip to content

Disable generation when .env is not present #205

Open

Description

@AndreLuizNogueira

When I run dart run build_runner build to update my drift database, envied_generator also regenerates the .env.g.dart file. However, when the .env file is missing, it generates a .env.g.dart file with empty values. Is it possible to prevent this? I would like to keep the existing file in that case, if possible.

Activity

  1. techouse commented on Aug 21, 2026

    @techouse
    Collaborator

    Hey!

    Hm, if anything this should throw an exception rather than keeping the previous .env.dart file.

  2. AndreLuizNogueira commented on Aug 22, 2026

    @AndreLuizNogueira
    Author

    Hey!

    Hm, if anything this should throw an exception rather than keeping the previous .env.dart file.

    Sorry, I meant the .env.g.dart file. I’ve corrected the question. I have the .env file, but the other collaborators only receive the generated file; whenever a new build occurs, they have to replace that generated file with a backup. This happens all the time.

  3. techouse commented on Aug 22, 2026

    @techouse
    Collaborator

    Hmm... So, if I understand this correctly, you git track the .env.g.dart file but not the .env file and when the other devs run the generator their .env.g.dart file gets overwritten?

  4. AndreLuizNogueira commented on Aug 22, 2026

    @AndreLuizNogueira
    Author

    Hmm... So, if I understand this correctly, you git track the .env.g.dart file but not the .env file and when the other devs run the generator their .env.g.dart file gets overwritten?

    Yeah. Then they always forget to copy the file back and compile the app, only to get an error message later about the blank fields. I want to solve this problem so I can stop wasting time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions