NAME

Developer::Dashboard::Guide::EnvFiles - layered environment files and variables

DESCRIPTION

Environment files and variables: layered .env and .env.pl loading, expansion forms, and the customisation variables.

This guide is part of the Developer::Dashboard manual. The main page is the front door for the whole set.

A diagram of layered env files: three stacked boxes, the home runtime .env, the project .env and the subfolder .env, with arrows pointing down and a note that a name set in two layers takes the deeper value.

Env files layer from the home runtime down to the folder you are standing in; the deeper layer wins.

Environment Customisation

After installing with cpanm, the runtime can be customised with these environment variables:

  • DEVELOPER_DASHBOARD_BOOKMARKS

    Overrides the saved page or bookmark directory.

  • DEVELOPER_DASHBOARD_CHECKERS

    Limits enabled collector or checker jobs to a colon-separated list of names.

  • DEVELOPER_DASHBOARD_CONFIGS

    Overrides the config directory.

  • DEVELOPER_DASHBOARD_ALLOW_TRANSIENT_URLS

    Allows browser execution of transient /?token=..., /action?atoken=..., and older /ajax?token=... payloads. The default is off, so the web UI only executes saved bookmark files unless this is set to a truthy value such as 1, true, yes, or on.

Collector definitions come only from dashboard configuration JSON, so config remains the single source of truth for path aliases, providers, collectors, and Docker compose overlays.

Environment Variables

The distribution supports these compatibility-style customisation variables:

  • DEVELOPER_DASHBOARD_BOOKMARKS

    Override the saved page root.

  • DEVELOPER_DASHBOARD_CHECKERS

    Filter enabled collector/checker names.

  • DEVELOPER_DASHBOARD_CONFIGS

    Override the config root.

  • DEVELOPER_DASHBOARD_ALLOW_TRANSIENT_URLS

    Allow browser execution of transient /?token=..., /action?atoken=..., and older /ajax?token=... payloads. The default is off, so the web UI only executes saved bookmark files unless this is set to a truthy value such as 1, true, yes, or on.

Layered Env Files

Environment files are part of the same DD-OOP-LAYERS contract. When dashboard ... runs, it loads every participating plain-directory env file and runtime-layer env file from parent to child before command hooks, custom commands, or built-in helpers execute. This is one interleaved pass, not a pass over all plain directories followed by a pass over all runtime directories.

For each directory from the selected root toward the current directory, the pass loads its plain .env and .env.pl files, then the .env and .env.pl files in runtime roots located under that directory. Sibling .d2 and .developer-dashboard roots retain their discovered order, with deeper directories loaded later. Explicit runtime roots outside the plain directory chain are loaded before that chain so child .env.pl files can read their inherited values. The participating files are:

  • <root>/.env

  • <root>/.env.pl

  • each deeper ancestor directory .env

  • each deeper ancestor directory .env.pl

  • each participating .developer-dashboard/.env and .d2/.env

  • each participating .developer-dashboard/.env.pl and .d2/.env.pl

Deeper files win because later layers overwrite earlier keys. Plain .env files must contain explicit KEY=VALUE lines, and the load order at one directory is always .env first and then .env.pl, followed by its runtime-root files. Plain .env parsing ignores blank lines, whole-line # comments, whole-line // comments, and /* ... */ block comments that can span multiple lines. Plain .env values also support:

  • leading ~ expansion to $HOME

  • $NAME expansion from the current effective environment

  • ${NAME:-default} expansion with a fallback value

  • ${Namespace::function():-default} expansion through a static Perl function

Expansion can see system env keys, values loaded from earlier layers, and values assigned by earlier lines in the same .env file. Missing functions, malformed lines, malformed keys, and unterminated block comments fail explicitly instead of being skipped silently. Executable logic can live in .env.pl, which is run directly and may set %ENV programmatically.

Skill-local env files are loaded only when a skill command or skill hook is actually running. A normal non-skill command inherits only the root-to-leaf runtime env chain. For a skill command, home-level runtime env files load first as defaults, then each participating skill root loads from the base installed skill layer to the deepest matching child skill layer, applying:

  • <skill-root>/.env

  • <skill-root>/.env.pl

Skill .env and .env.pl values override matching values from the home runtime. Skill cli/.env and cli/.env.pl values are applied after the skill root files.

Any deeper project runtime layers are applied last, so the nearest project runtime still has final precedence among file-based values. Values explicitly inherited from the invoking shell have highest precedence and are preserved across every env-file layer; a file may populate a variable that the caller did not set, but cannot replace an exported caller value.

Skill overrides stay isolated to the skill execution path and do not leak into unrelated commands.

The runtime chain is collected from the DD-OOP layers rooted at the current working directory, walking its existing parent directories toward the leaf. For skill execution, the home runtime portion is applied before the skill chain and deeper runtime layers after it. Therefore a nested command such as d2 foo.bar.bob receives home defaults, then the foo and bar skill overrides, then any nearer project runtime values.

For nested skill commands such as d2 foo.bar.zzz.show, the skill env chain expands from the root nested skill to the leaf skill before the command runs:

  • skills/foo/.env

  • skills/foo/skills/bar/.env

  • skills/foo/skills/bar/skills/zzz/.env

If a deeper nested skill overrides the same key, the parent value is preserved under that parent skill alias before the deeper skill replaces the plain key. For example, if all three nested skills assign VERSION, the leaf command sees VERSION from zzz, foo_VERSION from foo, and foo_bar_VERSION from foo.bar.

The Docker Compose resolver also loads <skill-root>/.env for each installed skill whose config/docker/<service>/compose.yml or config/docker/<service>/development.compose.yml file actually participates in the resolved compose stack. A service's compose.yml is its base and is loaded whenever present; development.compose.yml is loaded afterward only while the service's develop.yml marker is enabled.

That compose-only skill env layer stays isolated to the compose resolver, respects disabled skills, and does not execute <skill-root>/.env.pl.

Nested skill compose services use that same root-to-leaf env expansion, so a participating leaf service such as skills/foo/skills/bar/skills/zzz/config/docker/zzz/compose.yml loads the env chain from foo to foo.bar to foo.bar.zzz and preserves parent overrides under aliases such as foo_VERSION and foo_bar_VERSION.

Perl code can inspect where a dashboard-managed env key came from with Developer::Dashboard::EnvAudit.

Single-key lookup:

use Developer::Dashboard::EnvAudit;

my $entry = Developer::Dashboard::EnvAudit->key('FOO');

That returns either undef for normal system env keys or a hashref like:

{
    value   => 'bar',
    envfile => '/full/path/to/.env',
}

Full inventory lookup:

my $all = Developer::Dashboard::EnvAudit->keys;

The audit records only dashboard-loaded env keys. System-provided keys that did not come from a dashboard-managed .env or .env.pl file are left untracked on purpose.

For example, a layered .env file can now look like:

# root defaults
ROOT_CACHE=~/cache
API_BASE=https://example.test
TOKEN=${ACCESS_TOKEN:-anonymous}
MESSAGE=${Local::Env::Helper::message():-hello}

/*
child layers can still override
any value later in the root-to-leaf chain
*/
CHAINED=$ROOT_CACHE/$TOKEN

A separate mechanism, # include <skill.path>, pulls another skill's own .env/.env.pl in by name rather than by layer position - see Developer::Dashboard::Guide::Embedding for env->include(...), its .env.pl counterpart.

SEE ALSO

Developer::Dashboard