# `PtcRunner.Dotenv`
[🔗](https://github.com/andreasronge/ptc_runner/blob/main/lib/ptc_runner/dotenv.ex#L1)

Loads environment variables from `.env` files.

Walks up from a starting directory to find the nearest `.env` file
and sets variables that aren't already present in the environment.

## Examples

    # Load from nearest .env, only once per VM
    PtcRunner.Dotenv.load()

# `find_dotenv`

```elixir
@spec find_dotenv(String.t()) :: String.t() | nil
```

Find the nearest `.env` file by walking up from `dir`.

Returns the path to the first `.env` found, or `nil` if none exists up to
the filesystem root.

# `load`

```elixir
@spec load() :: :ok
```

Load environment variables from the nearest `.env` file.

Walks up from the current working directory looking for a `.env` file.
Only sets variables that aren't already set (existing env vars take precedence).
Safe to call multiple times — only loads once per VM.

# `load_file`

```elixir
@spec load_file(String.t()) :: :ok
```

Parse `path` as a `.env` file and set the variables it declares.

Lines are `KEY=VALUE`; blank lines and `#` comments are ignored. Surrounding
single or double quotes are stripped from the value. Existing environment
variables are never overwritten.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
