| Crates.io | rsenv |
| lib.rs | rsenv |
| version | 1.5.0 |
| created_at | 2023-08-14 13:20:42.398869+00 |
| updated_at | 2025-07-02 20:10:09.36623+00 |
| description | Hierarchical environment variable management |
| homepage | |
| repository | https://github.com/sysid/rs-env |
| max_upload_size | |
| id | 944159 |
| size | 163,662 |
Hierarchical environment variable management for modern development workflows
Managing environment variables across different environments (development, staging, production) and configurations (regions, features, services) is a common challenge in cloud-native projects. rsenv solves this by implementing hierarchical inheritance where child configurations automatically inherit and can override parent values.
Key Benefits:
.env files with parent-child relationships.env files as single-node trees$VAR and ${VAR} syntax in paths and comments# rsenv: parent.env
cargo install rs-env
git clone https://github.com/sysid/rs-env
cd rs-env/rsenv
cargo install --path .
Create linked environment files using # rsenv: comments:
# base.env
export DATABASE_HOST=localhost
export LOG_LEVEL=info
# production.env
# rsenv: base.env
export DATABASE_HOST=prod.example.com
export LOG_LEVEL=warn
export ENVIRONMENT=production
# Build complete environment from hierarchy
rsenv build production.env
# Load into current shell
source <(rsenv build production.env)
# Interactive selection with fuzzy finder
rsenv select environments/
# View tree structure
rsenv tree environments/
# Find all leaf environments
rsenv leaves environments/
# Edit entire hierarchy side-by-side
rsenv tree-edit environments/
# Update direnv integration
rsenv envrc production.env
# Link files programmatically
rsenv link base.env staging.env production.env
export VAR=value syntax (shell-compatible)# rsenv: parent.env comments for hierarchy# Basic parent reference
# rsenv: parent.env
# Multiple parents (creates DAG structure)
# rsenv: base.env shared.env
# Environment variable expansion
# rsenv: $HOME/config/base.env
# Flexible spacing (all valid)
# rsenv:parent.env
# rsenv: parent.env
# rsenv: parent.env
| Command | Description | Example |
|---|---|---|
build |
Build complete environment from hierarchy | rsenv build prod.env |
leaves |
List all leaf environment files | rsenv leaves environments/ |
tree |
Display hierarchical structure | rsenv tree environments/ |
branches |
Show linear representation of all chains | rsenv branches environments/ |
| Command | Description | Example |
|---|---|---|
select |
Interactive environment selection + direnv update | rsenv select environments/ |
edit |
Interactive selection and editing | rsenv edit environments/ |
tree-edit |
Side-by-side editing of hierarchies | rsenv tree-edit environments/ |
| Command | Description | Example |
|---|---|---|
envrc |
Update .envrc file for direnv | rsenv envrc prod.env .envrc |
files |
List all files in hierarchy | rsenv files prod.env |
link |
Create parent-child relationships | rsenv link base.env prod.env |
-d, --debug: Enable debug logging (use multiple times for increased verbosity)--generate: Generate shell completion scripts (bash, zsh, fish, powershell)--info: Display version and configuration informationdirenv provides automatic environment activation:
# Generate .envrc for automatic loading
rsenv envrc production.env .envrc
# Interactive selection with direnv update
rsenv select environments/
# Manual direnv commands
direnv allow # Enable .envrc
direnv reload # Refresh environment
Integration via EnvFile plugin:
#!/bin/bash
# runenv.sh
rsenv build "${RUN_ENV}.env"
runenv.shRUN_ENV environment variable in your run configurationGenerate completion scripts for your shell:
# Bash
rsenv --generate bash > ~/.bash_completion.d/rsenv
# Zsh
rsenv --generate zsh > ~/.zsh/completions/_rsenv
# Fish
rsenv --generate fish > ~/.config/fish/completions/rsenv.fish
git clone https://github.com/sysid/rs-env
cd rs-env/rsenv
cargo build --release
# Run all tests (single-threaded to prevent conflicts)
cargo test -- --test-threads=1
# Run with debug output
RUST_LOG=debug cargo test -- --test-threads=1
# Test via Makefile (includes interactive tests)
make test
src/lib.rs: Core environment expansion and tree building logicsrc/builder.rs: TreeBuilder for constructing hierarchical structuressrc/arena.rs: Arena-based tree data structuressrc/cli/: Command-line interface and command implementationstests/: Comprehensive test suite with example environmentstests/resources/environments/ demonstrate complex hierarchiescargo test -- --test-threads=1cargo fmtcargo clippy