API Reference
dotenvy
Loads environment variables from .env files in Rust, a maintained fork of the dotenv crate.
Official Documentation ↗CompatibilityThis documentation covers version
v0.15. Check the official docs for the latest API surface.Installation
cargo
cargo add dotenvyMethods
No methods match this filter.
dotenvy parses .env files and sets process environment variables, with typed accessors.
Key Features
- Load from default or named files
- Typed variable access
- Prefix and override control
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://docs.rs/dotenvy/latest/dotenvy/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:16.473Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- Structs § Iter Enums § Error Functions § dotenv Loads the .env file from the current directory or parents. (https://docs.rs/dotenvy/latest/dotenvy/)
FAQ
- Should .env be committed?
- No. Commit a .env.example with placeholder keys and keep real secrets in a gitignored .env or a secret manager.
- Does it override existing variables?
- No by default. Existing process variables take precedence, so real environment settings are not clobbered.
- How do I fail when a variable is missing?
- Read with var and propagate the error instead of using .ok(), so a missing required key aborts startup.
Report a problem with this API docOpens a pre-filled issue on GitHub.