Skip to main content

Crate dotenv

Crate dotenv 

Source
Expand description

Loads environment variables from .env files.

§Quick start

dotenv::load();

Call load near the start of your program to load a .env file from the current working directory.

§Precedence

  • Existing environment variables are never overwritten. A variable already set in the environment takes priority over anything in .env.
  • First declaration wins in .env. If the same key appears multiple times, only the first is used.

§Supported syntax

HELLO=world
HELLO="world"
HELLO='world'
HELLO='"nested"'
HELLO=world  # inline comment
# full-line comment

§Key names

Keys may only contain ASCII letters, digits, _, ., and -.

§Limitations

  • Multi-line values are not supported.
  • Variable substitution (e.g. ${FOO}) is not supported.
  • Export syntax (export KEY=value) is not supported.

Structs§

ParseError
A parse error with the line number and kind.

Enums§

Error
Errors that can occur when loading a .env file.
ParseErrorKind
The specific kind of parse error.

Functions§

load
Loads the .env file from the current working directory.