Hierarchical environment variable management for modern development workflows
Managing environment variables across different environments (development, staging, production) and
configurations (regions, features, services) creates massive duplication in traditional .env
files.
rs-env solves this by implementing hierarchical inheritance where child configurations automatically inherit and override parent values.
Environment files form directed acyclic graphs (DAGs) where:
- Child files link to parents via
# rsenv: parent.envcomments - Variables are inherited and merged from parent to child
- Child values override parent values (last defined wins)
- The
buildcommand compiles the complete environment
# From crates.io
cargo install rs-env
# From source
git clone https://github.com/sysid/rs-env
cd rs-env/rsenv
cargo install --path .Requirements: Rust 1.70+ (Install Rust)
Create a hierarchy where child environments inherit from parents:
# base.env - Shared configuration
export DATABASE_HOST=localhost
export LOG_LEVEL=info
# production.env - Inherits from base, overrides specific values
# rsenv: base.env
export DATABASE_HOST=prod-db.example.com
export LOG_LEVEL=error
export ENVIRONMENT=productionBuild the complete environment:
# Build production environment
rsenv build production.env
# Load into your shell
source <(rsenv build production.env)
# Verify
echo $DATABASE_HOST # prod-db.example.com (from production.env)
echo $LOG_LEVEL # error (from production.env)Result: production.env inherits base.env variables and overrides what changes. The # rsenv: base.env comment creates the parent-child link.
- Build environment trees from
.envfiles with parent-child relationships - Smart override logic: child variables automatically override parent values
- Standalone file support: independent
.envfiles work as single-node trees
- Fuzzy Selection - Built-in fuzzy finder for rapid environment discovery
- Smart Editing - Edit entire hierarchies side-by-side or individual files
- Tree Visualization - Display relationships and identify leaf nodes
- direnv - Automatic environment activation when entering directories
- JetBrains IDEs - Native IDE integration via EnvFile plugin
- Shell Completion - bash, zsh, fish, and powershell support
| Command | Purpose |
|---|---|
rsenv build <file> |
Build complete environment from hierarchy |
rsenv select <dir> |
Interactive selection + direnv update |
rsenv tree <dir> |
Display hierarchical structure |
rsenv edit <dir> |
Interactive selection and editing |
New to rs-env? Start with the Quick Start Guide
Comprehensive documentation is available in the rs-env Wiki:
- Getting Started: Quick Start, Installation, Core Concepts
- Core Features: Building Environments, Viewing Hierarchies, File Format
- Interactive Tools: Interactive Selection, Tree Editing
- Integrations: direnv, JetBrains IDEs, Shell Completion
- Advanced: Managing Links, Complex Hierarchies
- Reference: Command Reference, Troubleshooting
Contributions are welcome! See the Development Guide for details on building, testing, and contributing.
# Quick start for contributors
git clone https://github.com/sysid/rs-env
cd rs-env/rsenv
cargo test -- --test-threads=1
cargo build --releaseMIT License - see LICENSE for details.
