Skip to main content

load_dotenv

Function load_dotenv 

Source
pub fn load_dotenv(
    project_dir: impl AsRef<Path>,
    environment: &str,
) -> Result<(), ConfigError>
Expand description

Loads .env files from project_dir.

Order (missing files are skipped):

  1. .env
  2. .env.local (skipped when environment is prod)
  3. .env.{environment}
  4. .env.{environment}.local

Later files override earlier ones. Variables already present in the process environment before this call are never changed.

ยงErrors

Returns ConfigError::Dotenv when a present file fails to parse.