Skip to content

Where should the .env file be placed? #60

Answered by allan2
SquireOfSoftware asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @SquireOfSoftware,

Docs are on docs.rs. When a crate is published to crates.io, the docs are automatically generated.

  1. You can put the .env file(s) wherever you want. dotenv() picks up the first file named .env, looking in the current directory and then upward in the parent directories.
  2. I'm not sure if I would call it a best practice, but I like to have a single .env file at the project root for simplicity.
    If you are mimicking a production setup and would like to keep separate sets of environment variables, you could do:
dotenvy::from_path("/path/to/project/.env.backend")?;
dotenvy::from_path("/path/to/project/.env.frontend")?;
  1. There is from_path and from_filename. from_filename pic…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SquireOfSoftware
Comment options

Answer selected by SquireOfSoftware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants