envtrace
Trace where environment variables are defined and modified through shell startup sequences.
envtrace answers the question: "Where did this environment variable come from?"
Shell startup is complex -- variables can be set, overridden, or appended across dozens of files depending on your platform, shell, and whether you're in a login shell, a cron job, or a GUI app. envtrace walks the actual file chain and shows you exactly what happens.
Installation
From source
Pre-built binaries
Download from GitHub Releases.
Usage
Trace a variable (default mode)
# Trace PATH through the default shell context
# Trace in a specific context
# Verbose output (shows skipped files)
Find all definitions
# Search all config files regardless of context
Compare across contexts
# See how a variable differs between login and cron
Trace shell functions
# Trace a function definition
# Find all definitions of a function
# Compare a function across contexts
JSON output
System sanity checks
# Check config files for common issues
Platform Support
| Platform | Shell | Contexts |
|---|---|---|
| macOS | zsh | login, interactive, non-interactive, launchd agent/daemon |
| Linux | bash | login, interactive, non-interactive (cron), systemd service/user |
envtrace understands platform-specific differences:
- macOS uses
/etc/zshenv,/etc/zprofile,~/.zshrc, etc. - Linux uses
/etc/profile,/etc/profile.d/*.sh,~/.bashrc, etc. - macOS launchd agents use plist files (does not inherit shell env)
- Linux systemd services use unit files and environment.d
Building from Source
Requires Rust edition 2024 (rustc 1.85+).
The binary will be at target/release/envtrace.
Running tests
License
MIT