Problem
When a user's ~/.env contains values like:
DB_HOST=localhost
DB_PORT=5432
DATABASE_URL=${DB_HOST}:${DB_PORT}/dev
envoy currently copies ${DB_HOST}:${DB_PORT}/dev literally into the project .env. The resolved value — localhost:5432/dev — is what the project actually needs.
Proposed behavior
Before writing a value to the project .env, envoy resolves any variable references ($VAR or ${VAR}) found in the source value against the other keys present in ~/.env. The resolved string is written, not the template.
Resolution should:
- Follow the same left-to-right, defined-before-use ordering as shell variable expansion
- Detect and warn on circular reference loops rather than hanging
- Leave unresolvable references as-is (same non-destructive fallback behavior as missing keys today)
Open questions
- Should resolution be opt-in via a flag (
--resolve-vars) or always-on?
- How should nested references (variables that reference other variables) be handled?
- Should the resolution order be explicitly documented?
Related
Part of the feature roadmap.
Problem
When a user's
~/.envcontains values like:envoy currently copies
${DB_HOST}:${DB_PORT}/devliterally into the project.env. The resolved value —localhost:5432/dev— is what the project actually needs.Proposed behavior
Before writing a value to the project
.env, envoy resolves any variable references ($VARor${VAR}) found in the source value against the other keys present in~/.env. The resolved string is written, not the template.Resolution should:
Open questions
--resolve-vars) or always-on?Related
Part of the feature roadmap.