Skip to main content

from_path

Function from_path 

Source
pub fn from_path(path: impl AsRef<Path>) -> Result<(), Error>
Expand description

Loads a .env file from an explicit path.

Behaves like load but reads from path instead of ./.env. See load for the precedence rules and the thread-safety requirements.

§Errors

Returns Error if the file cannot be read or is malformed.

§Example

fn main() -> Result<(), dotenv::Error> {
    dotenv::from_path("config/.env")?;
    Ok(())
}