Kelly Mears

Environment Variable

A named value in a process's environment, inherited by its children — the standard configuration channel.

Systems & Tooling2 min read211 words13 out · 22 in
also calledEnv var

An environment variable is a name-value pair held in a process's environment and inherited by every process it spawns. It is the lowest-common-denominator configuration mechanism: available in every language, on every platform, and requiring no file format.

Its defining property is inheritance, which is also the source of most of its confusions. A variable set in one shell is invisible to another. A variable set at the session-manager level is inherited by everything, including things launched years later, which is how a stale credential set once can override a properly configured one indefinitely with no file anywhere to explain it. When a tool reports using the wrong identity, the first question is which source it actually read: an environment variable almost always takes precedence over a stored credential.

Two further points. The absence of a required variable should be fatal, not defaulted; see Fail Fast and Defensive Default. And making a variable required has a wide blast radius — every entry point that lacks it will now fail, including the ones nobody thinks about: the test configuration, the container image, the provisioning script, and the code-generation step in continuous integration.

Directory-scoped environment loaders make per-project variables ergonomic, which is how one machine can hold several isolated configurations for the same tool.

See also11

Dotfiles

A tracked repository of personal configuration, making a machine setup reproducible.

Systems & Tooling17 connections

XDG Base Directory Specification

A convention placing configuration, data, cache, and state in defined directories rather than the home directory.

Systems & Tooling11 connections

Terminal User Interface

An interface rendered as text in a terminal, and the design conventions that make command-line tools humane.

Graphics & Rendering16 connections

Shell

The interactive command interpreter, and a programming language with unusually sharp edges.

Systems & Tooling24 connections

Secret Management

Storing, distributing, and rotating credentials without embedding them in code or history.

Systems & Tooling33 connections

Containerization

Packaging an application with its dependencies into an isolated, reproducible runtime unit.

Systems & Tooling33 connections

Least Privilege

Granting only the permissions actually required, so a compromise has a small ceiling.

Systems & Tooling38 connections

Silent Failure

A failure that produces no signal, so the absence of an error reads as success.

Method73 connections

Gitignore

The file of patterns telling Git which files to leave untracked, such as build output, dependencies, editor clutter, and local secrets, along with the traps of files that were already tracked and secrets already committed.

Version Control & Delivery12 connections

Command-Line Interface

Operating a computer by typing commands and reading text replies, the interface inherited from teletypes that remains the fastest, most scriptable, and least discoverable way to control software.

Systems & Tooling14 connections

Shebang

The "#!" line at the top of a script that tells the kernel which interpreter should run it, so a text file can be executed like a compiled program, and the portability traps around it.

Systems & Tooling11 connections

Linked from22