3 unstable releases

new 0.1.1 Apr 25, 2025
0.1.0 Apr 20, 2025
0.0.1 Apr 18, 2025

#166 in Configuration

Download history 371/week @ 2025-04-17

371 downloads per month
Used in 3 crates (2 directly)

Unlicense

25KB
387 lines

Getenv.rs

License Compatibility Package Documentation

🚧 We are building in public. This is presently under heavy construction.

✨ Features

  • Implements a comprehensive set of environment variable getters for various platforms, programming languages, and tools.
  • Provides a wide range of varsets (variable sets), including for: AWS, Cargo, Conda, CUDA, Docker, Git, Go, Homebrew, Java, Locale, macOS, NEAR, Node.js, OpenSSL, POSIX, Proxy, Python, Ruby, Rust, SSH, Windows, and XDG.
  • Treats empty environment variables the same as missing ones.
  • Supports opting out of any feature using comprehensive feature flags.
  • Adheres to the Rust API Guidelines in its naming conventions.
  • 100% free and unencumbered public domain software.

🛠️ Prerequisites

⬇️ Installation

Installation via Cargo

cargo add getenv

Installation in Cargo.toml (with all features enabled)

[dependencies]
getenv = "0.1"

Installation in Cargo.toml (with only specific features enabled)

[dependencies]
getenv = { version = "0.1", default-features = false, features = ["posix"] }

👉 Examples

Importing the library

use getenv::*;

Reading environment variables

use getenv::aws::*;

println!("AWS_ACCESS_KEY_ID={:?}", aws_access_key_id());
println!("AWS_SECRET_ACCESS_KEY={:?}", aws_secret_access_key());

📚 Reference

Varset Feature Reference
aws aws use getenv::aws::*;
cargo cargo use getenv::cargo::*;
conda conda use getenv::conda::*;
cuda cuda use getenv::cuda::*;
docker docker use getenv::docker::*;
git git use getenv::git::*;
go go use getenv::go::*;
homebrew homebrew use getenv::homebrew::*;
java java use getenv::java::*;
locale locale use getenv::locale::*;
macos macos use getenv::macos::*;
near near use getenv::near::*;
node node use getenv::node::*;
openssl openssl use getenv::openssl::*;
posix posix use getenv::posix::*;
proxy proxy use getenv::proxy::*;
python python use getenv::python::*;
ruby ruby use getenv::ruby::*;
rust rust use getenv::rust::*;
ssh ssh use getenv::ssh::*;
windows windows use getenv::windows::*;
xdg xdg use getenv::xdg::*;

👨‍💻 Development

git clone https://github.com/dryrust/getenv.rs.git

Share on X Share on Reddit Share on Hacker News Share on Facebook Share on LinkedIn

Dependencies

~200–630KB
~15K SLoC