Skip to content

ctx version

ctx version prints the identity that was stamped into this binary at build time: the release version, the short git commit it was built from, and the build date.

Two situations. You’re filing a bug or comparing notes with a teammate and need the exact build, in which case you want the full line with the commit. Or you’re scripting — a setup script that enforces a floor version, a CI job that records the toolchain — in which case --short gives you the bare number and nothing to parse around.

It is also the fastest way to tell whether self-update will work at all: a binary that reports dev was built with go build/go install, has no release stamp, and ctx update will refuse to touch it.

Terminal window
ctx version
ctx version --short
ctx --version # root flag; version number only
FlagTypeDefaultDescription
--shortboolfalseprint just the version number
FlagTypeDefaultDescription
--rootstringproject root directory (default: current directory)

--root is inherited from the root command and has no effect here: ctx version reads no project files.

The full identity line — what to paste into a bug report:

Terminal window
ctx version
ctx version
ctx 0.5.1 (9f31c07, 2026-07-28)

Just the number, for scripts:

Terminal window
ctx version --short
ctx version --short
0.5.1

The three values come from package-level variables overridden at release build time with -ldflags -X …/internal/version.Version=…, .Commit=… and .Date=…. Nothing is read from disk, no config is loaded, and no network request is made — which is why this command works outside a Contexo project.

An un-stamped build falls back to the defaults dev, none and unknown, in that order, and IsDevBuild() — the predicate ctx update and the background update nudge both consult — is exactly the test Version == "dev".

ctx --version (or -v) is a different code path: it’s cobra’s built-in version flag on the root command, rendering ctx version <number> from the same Version variable, without the commit or date. Use the subcommand when you care about provenance.