Documentation

Unity command-line interface (CLI)

Download Unity Hub

Unity command-line interface (CLI)

Unity CLI output formats and automation

Configure Unity CLI output formats, handle errors and exit codes, and use environment variables to control CLI behavior in scripts, Continuous Integration (CI) pipelines, and agent workflows.
Read time 7 minutesLast updated 2 days ago

When you run the Unity CLI from a script, a CI pipeline, or an AI agent, use the output formats, error envelope, exit codes, and environment variables on this page to get predictable, machine-readable results and to handle failures without parsing text. The CLI chooses a default output format based on the context and supports explicit formats for automation.

Format selection

Format

Selected when

Notes

human
Output goes to an interactive terminal.Colorized, animated progress, aligned columns.
tsv
Output goes to a pipe or file.Tab-separated, one record per line. Machine-parseable.
json
You set
--format json
(or
--json
).
Structured output for use with
jq
and other tools. Uses a standard envelope with
success
,
command
,
data
,
errors
, and
warnings
.
ndjson
You set
--format ndjson
.
One JSON object per line. Long-running commands, such as
install
, stream typed progress frames and end with a result frame.
github
You set
--format github
.
Failures print as GitHub Actions annotations (
::error::...
,
::warning::...
) instead of plain text, so a red workflow step indicates what went wrong in its summary. Inert outside GitHub Actions.
Select a format explicitly with the global flag:
unity editors -i --format jsonunity editors -i --format tsvunity install lts --format ndjson
Note
--json
is accepted on every command as a global shorthand for
--format json
. When you supply both,
--format
takes precedence.
Tip
When you pipe CLI output, the default format changes to tab-separated values (TSV). If a script expects human-readable text, set
--format human
explicitly, or parse TSV, JSON, or NDJSON instead. Use
json
for a single buffered result and
ndjson
when you also want streamed progress frames from long-running commands.

Color output

Use the global
--color <auto|always|never>
flag to control colored output directly instead of relying only on the
NO_COLOR
and
FORCE_COLOR
environment variables.
--no-color
is shorthand for
--color never
. Color affects only
human
output. The
json
,
tsv
, and
ndjson
formats never emit color.

Error output

The CLI writes errors and diagnostic messages to
stderr
, leaving
stdout
available for data output. In
json
and
ndjson
modes, a failed command still writes a complete result to
stdout
. In
json
mode, the result is an envelope with
success: false
and an
errors
array. In
ndjson
mode, the result contains the terminal
result
frame with
success: false
. Branch on the stable error code, such as
errors[0].code
in
json
mode, instead of parsing
stderr
. Usage errors, such as a mistyped option, report
INVALID_COMMAND_ARGS
.
To capture both streams in a shell:
unity install 6000.3.7f1 > install.log 2>&1

Exit codes

Code

Meaning

0
Success.
1
A general error occurred. Inspect
stderr
for details.
2
Usage error: invalid flags, invalid option values, or missing required arguments.
3
Authentication or authorization failure, such as a rejected sign-in or an expired session.
4
Configuration required: the arguments are valid, but a required preference or context isn't set.
6
The command's primary operation failed. For example, an Editor install failed, or the Editor exited with an error. For
unity test
, the run didn't finish, so it produced no test results. Refer to
8
for more information.
7
A Unity service couldn't be reached, even after the CLI retried, or
unity recompile
couldn't reach a running Editor. Either is safe for a script to retry; a
6
is terminal.
8
unity test
only: The tests ran, and one or more failed. Scripts can't ever retry after exit code
8
.
130
The command was interrupted with Ctrl+C (
SIGINT
).
143
The command was terminated with
SIGTERM
, for example by
kill
or a CI runner timeout.
Note
When a CI job retries a failed
unity test
run, retry only exit code
6
or
7
. A
6
means the run didn't finish, for example because of a compile error, an unavailable license, an Editor crash, or
--timeout
, so a retry can still produce results. An
8
means the tests themselves failed, so a retry produces the same result.

Environment variables

Global CLI options have environment variable equivalents, and some behaviors are controlled only through the environment. A command-line flag takes precedence over its environment variable.

Variable

Effect

UNITY_FORMAT
Default output format (
human
,
json
,
tsv
,
ndjson
, or
github
).
HUB_FORMAT
remains supported as an alias.
UNITY_QUIET
Suppress non-essential output, like
--quiet
.
UNITY_NO_BANNER
Suppress the Unity banner, like
--no-banner
.
UNITY_NON_INTERACTIVE
Disable interactive prompts, like
--non-interactive
.
UNITY_PAGER
Pager for long human-readable output. Falls back to
PAGER
, then
less -RFX
. On Windows there is no built-in fallback: if neither variable is set and
less
is not on
PATH
, output is not paged.
UNITY_NO_PAGER
Never page output, like
--no-pager
.
UNITY_PROJECT_PATH
Default Unity project path for commands that accept
--project-path
.
UNITY_CLOUD_ORG
Default Unity Cloud organization for commands that accept
--cloud-org
.
UNITY_CLOUD_PROJECT
Default Unity Cloud project id for
unity collaboration
commands that accept
--project-id
. An explicit
--project-id
wins.
UNITY_PROXY
Proxy server URL, like
--proxy
.
UNITY_LOG_PROXY
Log one redacted entry per outbound request for proxy troubleshooting, like
--log-proxy
.
UNITY_INSTALL_RETRIES
Number of retries for module downloads that fail intermittently, like
--retries
.
0
disables retries.
UNITY_NO_ELEVATE
Windows only. Skip the elevated (UAC) install helper, like
--no-elevate
.
UNITY_BUILD_TIMEOUT
End
unity build
after this many seconds, similar to
--timeout
. Disabled by default.
UNITY_NO_UPDATE_CHECK
Disable the background check for CLI updates.
UNITY_NO_CLOUD
Create projects without the Unity Cloud step, like
--no-cloud
.
UNITY_INSTALL_MISSING_TOOLS
Allow an unattended run to install missing tools, such as Git LFS, without asking.
UNITY_SKIP_HOOKS
Turn the Git hooks installed by
unity vcs hooks install
into no-ops when Git provides no way to skip them.
UNITY_NO_CRASH_REPORT
Disable anonymous crash and error reporting.
UNITY_NO_CONSENT_PROMPT
Suppress the one-time first-run analytics consent prompt without recording a choice.
UNITY_ACCELERATOR
Unity Accelerator endpoint (
host:port
) for
unity run
,
unity test
, and
unity build
, like
--accelerator
. A bare host defaults to port 10080. A flag wins over this variable, which wins over the value saved with
unity config accelerator
.
UNITY_NO_EDITOR_IDENTITY_SERVER
Disables the background identity-server process that answers an Editor's sign-in requests when no Hub is running.
UNITY_NO_AUTH_BROKER
Disables the resident auth broker that serves your sign-in to CLI commands and read credentials directly from the keyring instead. The broker starts on demand and exits after two minutes of inactivity.
UNITY_CLI_HOME
Installation directory for the install script. When set, the script installs the CLI to
<UNITY_CLI_HOME>/bin
(
<UNITY_CLI_HOME>\bin
on Windows) instead of the default location.
UNITY_PEER_AUTH_MODE
Specifies how the CLI's background sign-in helpers verify the code signature of a connecting Editor or client. On macOS and Windows the default is
enforce
. Set
identify-only
to log without refusing, for example for an Editor you built from source. On Linux the default is logging only. Set
enforce
together with
UNITY_PEER_AUTH_LINUX_ALLOWED_HASHES
, a comma-separated list of trusted executable SHA-256 hashes to opt in.
UNITY_SERVICE_ACCOUNT_ID
,
UNITY_SERVICE_ACCOUNT_SECRET
Authenticate as a Unity service account for unattended workflows. Set both.

Progress output

Long-running commands (such as
install
) render animated progress bars on an interactive terminal and a static summary when complete. Progress output is for human readers. Don't parse it in scripts. For a machine-readable result, use
--format json
; to also stream machine-readable progress updates while the command runs, use
--format ndjson
, which emits typed progress frames followed by a final result frame.