envlock reads a JSON profile and prepares environment variables for your shell or child command.
Install latest release:
curl -fsSL https://raw.githubusercontent.com/PerishCode/envlock/main/scripts/install.sh | shInstall layout:
- Binary:
~/.envlock/bin/envlock - Symlink:
~/.local/bin/envlock
Run with sample profile from source:
cargo run -- -p examples/envlock.sample.jsonApply variables to current shell:
eval "$(cargo run --quiet -- -p examples/envlock.sample.json)"envlock (-p <path-to-profile.json> | --use <profile>) [--output <shell|json>] [--strict] [-- <cmd...>]
envlock preview --profile <path-to-profile.json> [--output <text|json>]
envlock self-update [--check] [--version <x.y.z|vX.Y.Z>] [-y|--yes]-p, --profile: JSON profile file path.--use <profile>: load profile fromENVLOCK_PROFILE_HOME/profiles/<profile>.json. IfENVLOCK_PROFILE_HOMEis unset, default is~/.envlock.--output <shell|json>: choose output mode (shellby default).--strict: fail on duplicate exported keys.-- <cmd...>: run a command with injected env in-process, and return the child exit code.--log-level <error|warn|info|debug|trace>: set log verbosity (default:warn).--log-format <text|json>: set log format (default:text).preview: read-only profile inspection without executing injections.--profile: profile file to inspect.--output <text|json>: preview rendering mode (textby default).- security boundary: preview only exposes metadata (for example env keys, command arg count), not sensitive values.
self-update: built-in updater for GitHub Release binaries.--check: only check whether an update is available.--version: upgrade to a specific release tag/version.-y, --yes: non-interactive confirmation.
env injections support ops for non-destructive env composition:
setset_if_absentprependappendunset
env values also support resource:// URI expansion:
resource://...resolves againstENVLOCK_RESOURCE_HOMEresource-content://...reads file content fromENVLOCK_RESOURCE_HOMEand injects it as the variable value- default resource home is
~/.envlock/resourceswhenENVLOCK_RESOURCE_HOMEis unset
Boundary:
- Use
envfor static values and simple composition. - Use
commandfor dynamic environment bootstrapping (for examplefnm env --shell bash).
{
"injections": [
{
"type": "env",
"enabled": true,
"vars": {
"ENVLOCK_PROFILE": "dev",
"ENVLOCK_NODE_VERSION": "22.11.0",
"NPM_CONFIG_REGISTRY": "https://registry.npmjs.org",
"KUBECONFIG_CONTEXT": "dev-cluster",
"KUBECONFIG_NAMESPACE": "platform"
},
"ops": [
{
"op": "prepend",
"key": "PATH",
"value": "~/.local/bin",
"separator": "os",
"dedup": true
},
{
"op": "set_if_absent",
"key": "NPM_CONFIG_REGISTRY",
"value": "https://registry.npmjs.org"
},
{
"op": "set",
"key": "KUBECONFIG",
"value": "resource://kubeconfig/xx.yaml:resource://kubeconfig/yy.yaml"
}
]
},
{
"type": "command",
"enabled": false,
"program": "fnm",
"args": ["env", "--shell", "bash"]
}
]
}Default output is shell exports:
export ENVLOCK_NODE_VERSION='22.11.0'
export NPM_CONFIG_REGISTRY='https://registry.npmjs.org'
export KUBECONFIG_CONTEXT='dev-cluster'
export KUBECONFIG_NAMESPACE='platform'JSON output:
cargo run --quiet -- -p examples/envlock.sample.json --output jsonCheck for updates:
envlock self-update --checkUpgrade interactively:
envlock self-updateUpgrade without prompt:
envlock self-update --yesUninstall:
curl -fsSL https://raw.githubusercontent.com/PerishCode/envlock/main/scripts/uninstall.sh | shFull documentation (VitePress + GitHub Pages):
CIworkflow (.github/workflows/ci.yml) runs on pull requests and pushes tomain.Releaseworkflow (.github/workflows/release.yml) runs on tag pushv*.- Multi-binary packaging is controlled by
TOOLSinrelease.yml. Add another binary name toTOOLSto include it in release artifacts. - Release workflow builds archives for:
x86_64-unknown-linux-gnux86_64-apple-darwinaarch64-apple-darwin
- Artifacts and
checksums.txtare published to GitHub Release.
Typical release steps:
- Merge to
mainafter CI passes. - Bump
Cargo.tomlversion toX.Y.Zand commit. - Create and push matching tag:
git tag vX.Y.Z && git push origin vX.Y.Z. - Wait for
Releaseworkflow to publish artifacts.
Release guardrails:
release.ymlvalidatesgithub.ref_name == v$(Cargo.toml version)and fails on mismatch.