Skip to main content

Module runner_env

Module runner_env 

Source
Expand description

The environment a native runner starts with, beyond what the daemon has.

A runner inherits the daemon’s environment, and a service’s environment is not a login shell’s. On macOS launchd starts the agent with PATH=/usr/bin:/bin:/usr/sbin:/sbin and no LANG, so a job finds no Homebrew tool (actions/cache falls back from zstd to gzip and never hits), and nothing the operator put in a shell profile reaches it. A classic runner gets those from the .env and .path files its config.sh writes; a just-in-time runner never runs config.sh.

Two things fill the gap, applied to every native runner in this order, each overriding the one before:

  1. Platform defaults (platform_defaults): on macOS, Homebrew’s directories ahead of the inherited PATH and a UTF-8 LANG; on Windows, a profile of the runner’s own (USERPROFILE, HOME, APPDATA, LOCALAPPDATA) inside the attempt, so concurrent jobs stop sharing the service account’s ~/.bun, npm cache and pnpm store. Every platform also gets POWERSHELL_TELEMETRY_OPTOUT=1 unless the daemon sets it (POWERSHELL_TELEMETRY_OPTOUT).
  2. The host’s runner.env (RunnerEnv): KEY=VALUE lines in the configuration directory, edited with runner-manager host env. A name set here replaces the platform default of the same name outright.

The per-attempt temporary directory (TMPDIR, TEMP, TMP) is applied last and cannot be overridden, and neither can GitHub’s ACTIONS_RUNNER_INPUT_* inputs, one of which carries the JIT configuration: RESERVED_NAMES and RESERVED_PREFIX.

§Not a secret store

The file is plain text in the configuration directory and every runner’s environment can read it back. Nothing here logs or prints a value except host env show, which exists to show them; errors name a line or a variable, never what it was set to.

Structs§

Inherited
What the daemon’s own environment holds, as far as the defaults care.
RunnerEnv
The parsed runner.env: ordered, one entry per name.

Enums§

RunnerEnvError
Why a runner.env line or assignment was refused, or the file could not be read or written. No variant carries a value.
RunnerPlatform
Which platform’s defaults to compute. A parameter rather than a cfg so that every leg of CI tests every platform’s rules.

Constants§

DIRECTORY_VARIABLES
The platform_defaults that name a directory the caller must create. Creating them creates the profile directory above them too.
MACOS_DEFAULT_LANG
The LANG a macOS runner gets when the daemon has none. It is what config.sh would have recorded from a default macOS terminal, and without a UTF-8 locale Ruby, CocoaPods and Python mis-handle non-ASCII text.
MACOS_SYSTEM_PATH
The PATH launchd gives a service, kept behind Homebrew’s directories when the daemon has no PATH of its own.
MACOS_TOOL_DIRECTORIES
macOS directories put ahead of the inherited PATH, when they exist and are not on it already: Apple Silicon Homebrew, then Intel Homebrew.
POWERSHELL_TELEMETRY_OPTOUT
The variable that turns PowerShell 7’s telemetry off. Every native runner gets it as 1 (POWERSHELL_TELEMETRY_OPTOUT_VALUE) unless the daemon’s environment already sets it to a non-empty value, which the runner then inherits as it is. An empty value counts as unset, as it does for PowerShell. runner.env replaces it like any other default, so POWERSHELL_TELEMETRY_OPTOUT=0 there turns telemetry back on.
POWERSHELL_TELEMETRY_OPTOUT_VALUE
The value POWERSHELL_TELEMETRY_OPTOUT is given. PowerShell accepts 1, true and yes, without regard to case.
RESERVED_NAMES
Names runner.env may not set, compared without regard to case: the temporary directory is per attempt, and cleanup and isolation rely on it.
RESERVED_PREFIX
The prefix of every name runner.env may not set: the listener reads each such variable as a command-line input, including the JIT configuration that registers it.
RUNNER_ENV_FILE
The file’s name inside the configuration directory.
RUNNER_HOME_DIR
The directory inside an attempt that is its runner’s profile on Windows.
WINDOWS_PROFILE_VARIABLES
The variables platform_defaults sets on Windows, in order: the profile directory twice, then its roaming and local application data.

Functions§

path_in
The runner.env path for a configuration directory.
platform_defaults
The variables platform sets for a runner whose attempt directory is runtime, before runner.env is applied.
runner_environment
The variables a native runner starts with on top of the daemon’s environment, in the order they must be applied: the platform defaults, then the dependency caches (crate::dependency_cache), then file. Applied in order the last value for a name wins, as it does for Command::env, so file overrides a cache or a default of the same name.
split_assignment
Splits a NAME=VALUE command-line argument.