Skip to content

sysid/rs-env

Repository files navigation

rsenv

Hierarchical environment variable management for modern development workflows

Documentation | Wiki

Crates.io License

Why rs-env?

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.

How It Works

Environment files form directed acyclic graphs (DAGs) where:

  1. Child files link to parents via # rsenv: parent.env comments
  2. Variables are inherited and merged from parent to child
  3. Child values override parent values (last defined wins)
  4. The build command compiles the complete environment

Concept

Quick Demo

Installation

# 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)

30-Second Example

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=production

Build 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.

Core Features

Hierarchical Inheritance

  • Build environment trees from .env files with parent-child relationships
  • Smart override logic: child variables automatically override parent values
  • Standalone file support: independent .env files work as single-node trees

Interactive Tools

  • 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

Integrations

  • direnv - Automatic environment activation when entering directories
  • JetBrains IDEs - Native IDE integration via EnvFile plugin
  • Shell Completion - bash, zsh, fish, and powershell support

Essential Commands

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

Full Command Reference

Documentation

New to rs-env? Start with the Quick Start Guide

Comprehensive documentation is available in the rs-env Wiki:

Contributing

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 --release

License

MIT License - see LICENSE for details.

Links

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages