Skip to main content
info

Documentation is currently for moon v2 and latest proto. Documentation for moon v1 has been frozen and can be found here.

Environment variables

moon interacts with environment variables in two directions:

info

moon embeds proto for toolchain management, so proto's own environment variables (like PROTO_HOME or PROTO_LOG) also apply. See the proto documentation for details. This page only documents moon's variables.

Variables moon sets

Within tasks

The following variables are injected into the environment of every task that moon runs, and can be referenced from within your commands, scripts, and .env files.

VariableDescription
MOON_CACHE_DIRAbsolute path to moon's cache directory (.moon/cache).
MOON_PROJECT_IDID of the project the running task belongs to.
MOON_PROJECT_ROOTAbsolute path to the project's root directory.
MOON_PROJECT_SOURCEThe project's source path, relative from the workspace root.
MOON_PROJECT_SNAPSHOTAbsolute path to a JSON snapshot of the project (the same data as moon project <id> --json), regenerated for each run.
MOON_TARGETFully-qualified target of the running task, e.g. app:build.
MOON_TASK_IDID of the running task.
MOON_TASK_HASHThe unique hash generated for the running task.
MOON_WORKSPACE_ROOTAbsolute path to the workspace root.
MOON_WORKING_DIRAbsolute path to the directory moon was invoked from.
PWDAbsolute path to the directory the task runs in — the project root, or the workspace root when runFromWorkspaceRoot is enabled.
note

Toolchains may inject additional variables (and prepend their binary directories to PATH) when setting up a task's environment. The variables above are always present regardless of toolchain.

During retries

When a task is retried (via retryCount), these are set for each attempt.

VariableDescription
MOON_TASK_RETRY_ATTEMPTThe current attempt number (starts at 1).
MOON_TASK_RETRY_TOTALThe total number of attempts that will be tried.

Affected files

When a task configures affectedFiles to pass results through the environment, moon sets the following.

VariableDescription
MOON_AFFECTED_FILESThe list of affected files (relative to the working directory), joined by the OS path delimiter. May be . or empty when there are no matches, depending on configuration.

Terminal & color

When pipeline.inheritColorsForPipedTasks is enabled (the default), moon inherits the terminal's color support into piped task processes.

VariableDescription
FORCE_COLORSet to the detected color support level so child processes emit color.
CLICOLOR_FORCESame as FORCE_COLOR, for tools that follow the CLICOLOR convention.
COLUMNSForced to 80 so cached output is consistent across machines.
LINESForced to 24 so cached output is consistent across machines.

NO_COLOR is removed from the task environment when colors are being forced.

proto integration

Set on task processes and any proto/toolchain child processes that moon spawns.

VariableValueDescription
PROTO_AUTO_INSTALLfalsePrevents proto from auto-installing tools during a task run.
PROTO_IGNORE_MIGRATE_WARNINGtrueSilences proto migration warnings.
PROTO_NO_PROGRESStrueDisables proto progress bars.
PROTO_VERSIONpinnedThe proto version pinned in .moon/toolchains.yml.
STARBASE_FORCE_TTYtrueForces TTY behavior for consistent output.

Internal

Set by moon for its own processes and integrations.

VariableDescription
MOON_VERSIONThe currently running moon version.
MOON_DAEMON_RUNNINGSet to true inside the daemon server process.
MOON_VCS_REPO_SLUGThe detected owner/repository slug, derived from the VCS remote (only if not already set).

Variables moon reads

Global options

Each of these has an equivalent global command line option. The command line option takes precedence over the environment variable.

VariableOptionDescription
MOON_CACHE--cacheMode for cache operations: read, read-write (default), write, or off.
MOON_COLOR--colorForce colored output.
MOON_CONCURRENCY--concurrencyMaximum number of threads to utilize. Defaults to the number of CPU cores.
MOON_DUMP--dumpDump a trace profile to the working directory.
MOON_LOG--logLowest log level to output: off, error, warn, info (default), debug, trace, verbose.
MOON_LOG_FILE--log-filePath to a file to write logs to.
MOON_QUIET--quietHide all moon console output.
MOON_THEME--themeTerminal theme to print with.

Running tasks & the pipeline

Read by moon exec, moon run, moon check, and moon ci. Most map to a command line option.

VariableOptionDescription
MOON_FORCE--forceForce run and bypass cache, ignore changed files, and skip affected checks.
MOON_NO_ACTIONS--no-actionsRun the pipeline without sync and setup related actions.
MOON_EXEC_PLAN--planRelative path to an execution plan (JSON) that customizes the action graph.
MOON_SUMMARY--summaryPrint a summary of all actions that ran in the pipeline.
MOON_JOB--jobZero-based index of the current job (for CI job sharding).
MOON_JOB_TOTAL--job-totalTotal amount of jobs to run.
MOON_AFFECTED--affectedOnly run tasks affected by changed files.
MOON_BASE--baseBase branch, commit, or revision to compare affected against.
MOON_HEAD--headCurrent branch, commit, or revision to compare with.
MOON_INCLUDE_RELATIONS--include-relationsInclude graph relations for affected checks, instead of just changed files.
MOON_ON_FAILURE--on-failureWhen a task fails, either bail the pipeline or continue executing.
MOON_OUTPUT_STYLEThe outputStyle task option in which output is printed.
MOON_RETRY_COUNTThe retryCount task option — number of times a failing task is retried.

Skipping actions

Skip individual pipeline actions. Set to true (or 1, *) to skip all, or provide a comma-separated list of project IDs / toolchain IDs / targets to skip only those that match.

VariableDescription
MOON_SKIP_SYNC_WORKSPACESkip the SyncWorkspace action.
MOON_SKIP_SYNC_PROJECTSkip SyncProject actions (matches project IDs).
MOON_SKIP_SETUP_TOOLCHAINSkip SetupToolchain actions (matches toolchain IDs).
MOON_SKIP_SETUP_ENVIRONMENTSkip SetupEnvironment actions (matches toolchain IDs).
MOON_SKIP_INSTALL_DEPSSkip InstallDependencies actions (matches toolchain IDs).

Toolchain versions

MOON_<TOOLCHAIN>_VERSION overrides the version of a toolchain configured in .moon/toolchains.yml, where <TOOLCHAIN> is the uppercased toolchain ID. This is especially useful for testing against multiple versions in a CI matrix.

For example:

$ MOON_NODE_VERSION=20.0.0 moon run app:build
$ MOON_RUST_VERSION=1.90.0 moon run app:build

Configuration overrides

Override .moon/workspace.yml settings without editing the file.

VariableSetting
MOON_DAEMONdaemon
MOON_TELEMETRYtelemetry
MOON_WEBHOOK_URLnotifier.webhookUrl
MOON_WEBHOOK_ACKNOWLEDGEnotifier.webhookAcknowledge
MOON_PIPELINE_AUTO_CLEAN_CACHEpipeline.autoCleanCache
MOON_PIPELINE_CACHE_LIFETIMEpipeline.cacheLifetime
MOON_PIPELINE_KILL_PROCESS_THRESHOLDpipeline.killProcessThreshold

Remote caching v1.30.0

Override remote settings for remote caching.

VariableSetting / description
MOON_REMOTE_HOSTremote.host — gRPC host to connect to.
MOON_REMOTE_APIremote.api — API format of the remote service.
MOON_REMOTE_AUTH_TOKENremote.auth.token — name of the env var to use as a bearer token.
MOON_REMOTE_CACHE_*Override remote.cache fields (e.g. MOON_REMOTE_CACHE_COMPRESSION, MOON_REMOTE_CACHE_INSTANCE_NAME).
MOON_REMOTE_TLS_HTTP2remote.tls.assumeHttp2.
MOON_REMOTE_TLS_*Override remote.tls fields.
MOON_REMOTE_MTLS_HTTPremote.mtls.assumeHttp2.
MOON_REMOTE_MTLS_*Override remote.mtls fields.

Experiments

Toggle experiments. Accepts a boolean-like value (true, 1, false, 0).

VariableSetting
MOON_EXPERIMENT_ASYNC_AFFECTED_TRACKINGexperiments.asyncAffectedTracking
MOON_EXPERIMENT_ASYNC_GRAPH_BUILDINGexperiments.asyncGraphBuilding
MOON_EXPERIMENT_CAS_OUTPUTS_CACHEexperiments.casOutputsCache
MOON_EXPERIMENT_NATIVE_FILE_HASHINGexperiments.nativeFileHashing

Debugging

Declare any of these (to a truthy value) to reveal additional diagnostic output. See debugging for more.

VariableDescription
MOON_DEBUG_PROCESS_ENVReveal the full environment passed to processes. By default moon hides everything except MOON_* variables to avoid leaking secrets.
MOON_DEBUG_PROCESS_INPUTReveal the full stdin passed to processes, instead of truncating it.
MOON_DEBUG_REMOTEExtra logging for remote caching, including internal connection errors.
MOON_DEBUG_WASMExtra logging for WASM plugins, and optionally dumps memory/core profiles.
MOON_DEBUG_DAEMONExtra logging for the daemon.
MOON_DEBUG_MCPExtra logging for the MCP server.

Graph visualizer

Read by the graph commands (project-graph, task-graph, action-graph) when starting the local visualization server.

VariableOptionDescription
MOON_HOST--hostThe host address to bind the server to. Defaults to 127.0.0.1.
MOON_PORT--portThe port to bind to. Defaults to 0 (a random open port).
MOON_JS_URLOverride the URL of the visualizer JavaScript bundle (advanced).

Store & installation

VariableDescription
MOON_HOMEOverride moon's store directory. Defaults to ~/.moon (or $XDG_DATA_HOME/moon when XDG_DATA_HOME is set).
MOON_INSTALL_DIRDirectory that moon upgrade installs the binary into. Defaults to ~/.moon/bin.

Advanced

VariableDescription
MOON_TOOLCHAIN_FORCE_GLOBALSForce toolchains to use globally installed tools instead of proto-managed versions. Set automatically within Docker.
MOON_PLUGINS_USE_URL_DISTLoad plugins from their URL distribution instead of a locally built artifact.
MOON_VCS_REPO_SLUGOverride the detected owner/repository slug (see above).
MOON_TRACE_IDA trace/correlation ID included in webhook payloads.

System variables

moon also inspects a number of standard, third-party variables to detect the current environment. These are read, never written.

Variable(s)Purpose
CI, CI_NAME, AZURE_PIPELINESDetect whether moon is running in a CI environment.
NO_COLOR, FORCE_COLOR, CLICOLOR, CLICOLOR_FORCEStandard color output controls, honored and propagated.
XDG_DATA_HOMEFallback location for moon's store directory.
SSH_CLIENT, SSH_TTYDetect a remote SSH session.
CODESPACES, GITHUB_CODESPACES, GITPOD_INSTANCE_ID, DEVPOD, REPL_ID, and similarDetect a cloud development environment ("devbox").
PATHResolve binaries, and the base that toolchains prepend their bin directories to.