MCPcopy Index your code
hub / github.com/allan2/dotenvy

github.com/allan2/dotenvy @v0.15.7

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.15.7 ↗ · + Follow
135 symbols 290 edges 32 files 42 documented · 31% updated 3mo agov0.15.7 · 2023-03-22★ 1,21932 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

dotenvy

Crates.io msrv
1.56.1 ci docs

A well-maintained fork of the dotenv crate.

This crate is the suggested alternative for dotenv in security advisory RUSTSEC-2021-0141.

This library loads environment variables from a .env file. This is convenient for dev environments.

Components

  1. dotenvy crate - A well-maintained fork of the dotenv crate.
  2. dotenvy_macro crate - A macro for compile time dotenv inspection. This is a fork of dotenv_codegen.
  3. dotenvy CLI tool for running a command using the environment from a .env file (currently Unix only)

Usage

Loading at runtime

use dotenvy::dotenv;
use std::env;

fn main() {
    // load environment variables from .env file
    dotenv().expect(".env file not found");

    for (key, value) in env::vars() {
        println!("{key}: {value}");
    }
}

Loading at compile time

The dotenv! macro provided by dotenvy_macro crate can be used.

Minimum supported Rust version

Currently: 1.56.1

We aim to support the latest 8 rustc versions - approximately 1 year. Increasing MSRV is not considered a semver-breaking change.

Why does this fork exist?

The original dotenv crate has not been updated since June 26, 2020. Attempts to reach the authors and present maintainer were not successful (dotenv-rs/dotenv #74).

This fork intends to serve as the development home for the dotenv implementation in Rust.

What are the differences from the original?

This repo fixes:

  • home directory works correctly (no longer using the deprecated std::env::home_dir)
  • more helpful errors for dotenv! (dotenv-rs/dotenv #57)

It also adds:

  • multiline support for environment variable values
  • io::Read support via from_read and from_read_iter
  • improved docs

For a full list of changes, refer to the changelog.

Contributing

Thank you very much for considering to contribute to this project! See CONTRIBUTING.md for details.

Note: Before you take the time to open a pull request, please open an issue first.

The legend

Legend has it that the Lost Maintainer will return, merging changes from dotenvy into dotenv with such thrust that all Cargo.tomls will lose one keystroke. Only then shall the Rust dotenv crateverse be united in true harmony.

Until then, this repo dutifully carries on the dotenv torch. It is actively maintained.

Core symbols most depended-on inside this repo

assert_parsed_string
called by 13
dotenv/src/parse.rs
dotenv
called by 9
dotenv/src/lib.rs
find
called by 8
dotenv/src/find.rs
var
called by 7
dotenv/src/lib.rs
load
called by 7
dotenv/src/iter.rs
skip_whitespace
called by 4
dotenv/src/parse.rs
load_override
called by 4
dotenv/src/iter.rs
expect_equal
called by 3
dotenv/src/parse.rs

Shape

Function 90
Method 35
Class 6
Enum 4

Languages

Rust100%

Modules by API surface

dotenv/src/parse.rs34 symbols
dotenv/tests/integration/util/testenv.rs26 symbols
dotenv/src/lib.rs14 symbols
dotenv/src/errors.rs12 symbols
dotenv/src/iter.rs9 symbols
dotenv/src/find.rs5 symbols
dotenv/tests/integration/util/mod.rs4 symbols
examples/dev-prod/src/main.rs3 symbols
dotenv_codegen/src/lib.rs3 symbols
dotenv_codegen/tests/basic_dotenv_macro.rs2 symbols
dotenv/tests/common/mod.rs2 symbols
dotenv/src/bin/dotenvy.rs2 symbols

For agents

$ claude mcp add dotenvy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact