Where should the .env file be placed? #60
-
I feel like this is a fairly obvious question but I am also fairly certain that my rust/crate naivety is also at play here. Where should the .env file be placed?I have a project that I have been tinkering away with and I have it set up like so:
And I noticed that if I run: So I have two general questions:
Feel free to let me know if these questions are also invalid because I have just come off the Rust book fairly recently and was curious about the actual behaviour of And also feel free to point me to documentation to read since it seems my googlefu is failing me on these questions. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Docs are on docs.rs. When a crate is published to crates.io, the docs are automatically generated.
dotenvy::from_path("/path/to/project/.env.backend")?;
dotenvy::from_path("/path/to/project/.env.frontend")?;
Hope this helps! Let me know if you have any other questions. |
Beta Was this translation helpful? Give feedback.
Hi @SquireOfSoftware,
Docs are on docs.rs. When a crate is published to crates.io, the docs are automatically generated.
dotenv()
picks up the first file named .env, looking in the current directory and then upward in the parent directories.If you are mimicking a production setup and would like to keep separate sets of environment variables, you could do:
from_path
andfrom_filename
.from_filename
pic…