CLI reference¶
This reference covers every vc-env command implemented by the project.
Conventions:
- Commands return exit code
0on success. - On errors, commands typically print an error message to stderr and exit with code
1. - Every command accepts
-h/--help, prints its help and exits0without doing anything else (upgrade --helpnever upgrades). execexits with the child process's exit code.
Command summary¶
| Command | What it does |
|---|---|
help |
Print usage and the list of commands |
version |
Print the vc-env version |
init |
Create the VCENV_ROOT layout and print shell integration code |
list |
List installed vcluster versions |
list-remote |
List vcluster versions available on GitHub |
latest |
Print the latest vcluster release on GitHub |
install |
Download, checksum-verify and install a vcluster version |
uninstall |
Remove an installed vcluster version |
shell |
Set or show the shell-level version (VCENV_VERSION) |
local |
Set or show the directory-level version (.vcluster-version) |
global |
Set or show the global default ($VCENV_ROOT/version) |
which |
Print the full path to the active vcluster binary |
upgrade |
Replace the current vc-env binary with the latest release |
exec |
Run vcluster at a specific version for a single command |
resolve |
Print the concrete installed version for a spec (or the active version) |
status |
Show VCENV_ROOT, resolved version, source and all installed versions |
doctor |
Diagnose the environment and optionally repair it |
prune |
Remove installed versions nothing references |
completion |
Generate a native completion script for bash, zsh, fish or powershell |
ensure is an advanced / internal command.
Global usage¶
Top-level help is available via vc-env help, vc-env --help, or vc-env -h.
Environment variables¶
VCENV_ROOT¶
Required. Path where vc-env stores installed versions and shims.
Used by most commands and required for initialization.
VCENV_VERSION¶
Optional. When set, it forces a particular vcluster version to be used (highest priority).
Typically set via vc-env shell after enabling shell integration with eval "$(vc-env init)".
VCENV_AUTO_INSTALL¶
Optional. When set to 1, the vcluster shim automatically installs missing
versions on demand instead of failing with an error. This is especially useful
for teammates cloning a repository with a .vcluster-version file.
It also makes vc-env resolve and vc-env exec install missing versions
(as if --install / --auto were passed; exec --no-auto opts out).
Internally the shim calls vc-env resolve --install --silent, which resolves
aliases (latest, 0.21, ~0.21.1, …) to a concrete version before
installing.
VCENV_GITHUB_TOKEN¶
Optional. GitHub personal access token used to authenticate requests to the GitHub API (and asset downloads from private mirrors / GHES). When set it is sent as Authorization: Bearer <token> on every GitHub request issued by vc-env, raising the anonymous rate limit (60/h) to the authenticated limit (5000/h).
Takes precedence over GITHUB_TOKEN so that a shell-wide GITHUB_TOKEN cannot silently change vc-env behaviour.
GITHUB_TOKEN¶
Optional. Fallback GitHub token used only when VCENV_GITHUB_TOKEN is unset. Convenient in CI environments where GITHUB_TOKEN is already injected by the runner (for example GitHub Actions).
VCENV_GITHUB_API_URL¶
Optional. Overrides the GitHub API base URL (default https://api.github.com). Set this to point vc-env at a GitHub Enterprise Server instance, for example https://ghe.example.com/api/v3.
VCENV_DOWNLOAD_MIRROR¶
Optional. Overrides the asset download base URL (default https://github.com). Set this to pull vcluster and vc-env release assets from an internal mirror (for air-gapped environments). Every download honours it: install, auto-install (shim, resolve --install, exec --auto), doctor --deep, and upgrade.
VCENV_CACHE_TTL¶
Optional. How long the on-disk release cache ($VCENV_ROOT/cache/releases.json)
is considered fresh, as a Go duration such as 30m or 6h. Default 1h.
Invalid values fall back to the default. See caching strategy.
VCENV_PRUNE_SCAN_ROOTS¶
Optional. Directories that prune scans for .vcluster-version
files, separated by the OS path-list separator (: on Linux and macOS).
Unset: scan $HOME. Set to an empty string: disable scanning (useful on CI
runners and servers).
Version aliases¶
Several commands (install, global, local, shell, resolve, exec)
accept version aliases in addition to concrete versions. Aliases are stored
verbatim when written to .vcluster-version, $VCENV_ROOT/version, or
VCENV_VERSION, and are re-resolved on every shim call.
| Alias | Meaning |
|---|---|
latest, latest-stable |
Newest non-prerelease release |
latest-prerelease |
Newest release including prereleases |
MAJOR.MINOR (e.g. 0.21) |
Highest patch of that minor |
~MAJOR.MINOR.PATCH (e.g. ~0.21.1) |
Highest version >=0.21.1 <0.22.0 |
resolve, exec and the shim match installed versions first (fast, offline;
latest means the newest installed stable version). They consult the remote
release list only when nothing installed matches and installing is allowed
(--install, --auto or VCENV_AUTO_INSTALL=1). install always resolves
aliases against the remote release list.
Commands¶
help¶
Purpose: Print usage and the list of available commands.
Syntax:
Options/flags: none.
Environment variables: none.
Exit codes:
0always.
Example:
version¶
Purpose: Print the vc-env version.
Syntax:
Options/flags: none.
Environment variables: none.
Exit codes:
0on success.
Example:
init¶
Purpose:
- Create required directories under
VCENV_ROOT. - Generate the
vclustershim under$VCENV_ROOT/shims/vcluster. - Print shell initialization code to stdout (intended to be evaluated by your shell).
Syntax:
Options/flags:
-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)
Exit codes:
0on success.1ifVCENV_ROOTis not set or filesystem operations fail.
Eval, not source
vc-env init emits shell code to stdout; eval "$(vc-env init)"
is what makes the shim and the vc-env shell function available in
the current shell.
Example:
list¶
Purpose: List installed vcluster versions (newest to oldest).
Syntax:
Options/flags:
-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)
Exit codes:
0on success.1ifvc-envis not initialized.
Example:
list-remote¶
Purpose: List all available vcluster versions from GitHub releases (newest to oldest).
This command does not require VCENV_ROOT or initialization. If VCENV_ROOT is set, results are persistently cached on disk (see caching strategy).
Syntax:
Options/flags:
--prerelease: include pre-release versions (alpha, beta, rc)-h,--help: show command help and exit
Environment variables: none.
Exit codes:
0on success, or when printing--help.1on GitHub/network errors (including rate limiting).
Example:
latest¶
Purpose: Print the latest available vcluster version from GitHub releases.
This command does not require VCENV_ROOT or initialization. If VCENV_ROOT is set, results are persistently cached on disk (see caching strategy).
Syntax:
Options/flags:
--prerelease: include pre-release versions when selecting the latest-h,--help: show command help and exit
Environment variables: none.
Exit codes:
0on success, or when printing--help.1if no versions are found, or on GitHub/network errors.
Example:
install¶
Purpose: Download and install a vcluster version into $VCENV_ROOT/versions/<version>/vcluster.
If <version> is omitted, vc-env installs the latest stable version. An
alias (e.g. latest, 0.21, ~0.21.1) is resolved first and the concrete
version is then installed. See Version aliases.
The command displays a progress bar during the download and automatically verifies the integrity of the downloaded file using SHA256 checksums from the GitHub release.
Syntax:
Options/flags:
-s,--silent: do not display the progress bar or checksum verification information--from-file <path>: install the given local file as the vcluster binary instead of downloading. Requires a concrete<version>argument and skips all network calls (air-gapped setups). Combine with--sha256to verify integrity.--sha256 <hex>: expected hex-encoded SHA-256 of the binary. Overrides the checksums.txt from the GitHub release and applies to both remote and--from-fileinstalls. A mismatch aborts installation.-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)
Exit codes:
0on success.1if not initialized, platform detection fails, download fails, checksum mismatch, or filesystem writes fail.
Rate limits and air-gapped environments
Without a token, GitHub applies a 60 requests/hour anonymous limit
per IP, which is easy to exhaust on shared CI runners. Export
VCENV_GITHUB_TOKEN (or GITHUB_TOKEN in CI) to raise it to
5000/h. To pull assets from a mirror instead of github.com, set
VCENV_DOWNLOAD_MIRROR.
Example:
vc-env install 0.21.1
vc-env install --silent
vc-env install
vc-env install 0.21 # highest 0.21.x
vc-env install ~0.21.1 # >=0.21.1 <0.22.0
vc-env install latest
# Air-gapped install from a pre-downloaded binary:
vc-env install 0.21.1 --from-file ./vcluster --sha256 <hex>
uninstall¶
Purpose: Remove an installed vcluster version directory.
Syntax:
Options/flags:
-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)
Exit codes:
0on success.1if<version>is missing, not initialized, the version is not installed, or filesystem removal fails.
Example:
shell¶
Purpose: Set or show the shell-level vcluster version.
The <version> argument may be a concrete version (which must be installed)
or an alias (latest, 0.21, ~0.21.1, …). Aliases are stored verbatim and
re-resolved by the shim on every vcluster call. See
Version aliases.
Requires shell integration
To set the version for your current shell session, you must have
shell integration enabled via eval "$(vc-env init)". Otherwise,
you will only see the printed export … line but your current
shell will not be updated.
Syntax:
Options/flags:
-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)VCENV_VERSION(read on show; written when you eval shell integration)
Exit codes:
0on success.1if not initialized, no shell version is configured (show), or the requested version is not installed (set).
Example:
local¶
Purpose: Set or show the local (directory-level) vcluster version.
Setting writes a .vcluster-version file into the current directory. The
value may be a concrete version or an alias (latest, 0.21, ~0.21.1, …).
Aliases are stored verbatim and re-resolved by the shim on every vcluster
call. See Version aliases.
Syntax:
Options/flags:
-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)
Exit codes:
0on success.1if not initialized, no local version is configured for this directory (show), the requested version is not installed (set), or writing.vcluster-versionfails.
Example:
global¶
Purpose: Set or show the global default vcluster version.
Setting writes $VCENV_ROOT/version. The value may be a concrete version or
an alias (latest, 0.21, ~0.21.1, …). Aliases are stored verbatim and
re-resolved by the shim on every vcluster call. See
Version aliases.
Syntax:
Options/flags:
-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)
Exit codes:
0on success.1if not initialized, no global version is configured (show), the requested version is not installed (set), or writing fails.
Example:
which¶
Purpose: Print the full path to the active vcluster binary that would be used based on version resolution.
Syntax:
Options/flags:
-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)VCENV_VERSION(optional; highest priority if set)
Exit codes:
0on success.1if not initialized or no version is configured.
Example:
upgrade¶
Purpose: Fetch the latest vc-env release from GitHub (mmpyro/vc-env), verify
its SHA-256 against the release's checksums.txt, and replace the current
binary in place.
Syntax:
Options/flags:
-h,--help: show command help and exit (never upgrades)
Environment variables:
VCENV_GITHUB_TOKEN/GITHUB_TOKEN: GitHub token for the release lookupVCENV_GITHUB_API_URL: GitHub API base URLVCENV_DOWNLOAD_MIRROR: download base URL for the binary and checksums
The binary path is auto-detected via os.Executable().
Exit codes:
0on success, when already up to date, or when printing--help.1on network/download errors, checksum mismatch, permission issues, or filesystem errors.
Notes:
- The command detects the current OS and CPU architecture automatically.
- The new binary is written atomically (temp file + rename) to avoid corruption.
- If the current version is a development build (
dev), the upgrade always proceeds.
Example:
¶
exec¶
Purpose: Run a specific version of vcluster for a single command without changing the active version (shell, local, or global).
One-off calls
exec is the right tool when you need a different vcluster
version for a single command and don't want to touch any of the
three persistent sources (VCENV_VERSION, .vcluster-version,
$VCENV_ROOT/version).
Syntax:
The version is resolved like resolve: installed versions first.
Everything after the version is passed to vcluster; a single leading -- is
stripped, so vc-env exec 0.21 -- --help runs vcluster --help.
Options/flags (only before the version):
--auto: install the version if it is missing--no-auto: never install, even whenVCENV_AUTO_INSTALL=1-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)VCENV_AUTO_INSTALL(1implies--auto)VCENV_VERSION(set to the concrete version for the subprocess)
Exit codes:
- The exit code of
vcluster, passed through unchanged. 1if not initialized, or the version is not installed and cannot be auto-installed.
Example:
¶
status¶
Purpose: Display a comprehensive overview of the current vc-env environment.
Output includes:
VCENV_ROOTpath.- Currently active version and the source it was resolved from.
- Full path to the active
vclusterbinary. - List of all installed versions (active one marked with
*).
Syntax:
Options/flags:
-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)VCENV_VERSION(read if set)
Exit codes:
0on success.1on error.
Example:
doctor¶
Purpose: Diagnose the vc-env environment and print one [OK], [WARN],
[FAIL] or [INFO] line per check, with a hint on how to fix problems.
Checks, in order:
VCENV_ROOTis set.- The root exists and is writable.
$VCENV_ROOT/versionsexists.- The shim exists and matches what
vc-env initwould generate. $VCENV_ROOT/shimsis onPATH, ahead of any othervcluster.- A shell rc file (
~/.bashrc,~/.zshrc,~/.config/fish/config.fish) containsvc-env init(informational only). - The active version is configured; aliases are resolved offline against installed versions.
- The active binary exists and is executable.
- Every installed binary is executable, and no version directory lacks a binary.
- The GitHub API (
VCENV_GITHUB_API_URL) is reachable, with a warning when the rate-limit headroom is low. - The release cache is valid JSON.
- With
--deep: each installed binary's SHA-256 matches its release'schecksums.txt.
Syntax:
Options/flags:
--fix: regenerate the shim and make installed binaries executable, then re-run the checks. It never editsPATHor shell rc files.--deep: download each installed version'schecksums.txtand compare the entry for this platform with the on-disk binary (one small download per version)-h,--help: show command help and exit
Environment variables:
VCENV_ROOT,VCENV_VERSION,PATH,HOMEVCENV_GITHUB_TOKEN/GITHUB_TOKEN,VCENV_GITHUB_API_URL,VCENV_DOWNLOAD_MIRRORVCENV_AUTO_INSTALL(1downgrades a missing active version from FAIL to WARN, since the shim installs it on first use)
Exit codes:
0if no check reportedFAIL.1if at least one check reportedFAIL.
Example:
prune¶
Purpose: Remove installed versions that nothing references. Dry run by
default: nothing is deleted without --yes.
A version is kept when it is:
- the global version (
$VCENV_ROOT/version), - the exported
VCENV_VERSION, - named in a
.vcluster-versionfile under the scan roots (VCENV_PRUNE_SCAN_ROOTS, default$HOME), - the currently active version (shell > local > global), or
- among the
--keep-lastnewest installed versions.
Aliases are alias-aware: a reference to 0.21 or latest keeps the installed
version it currently resolves to. The scan skips noisy directories such as
.git, node_modules, vendor and ~/Library, and never enters VCENV_ROOT.
Syntax:
Options/flags:
--keep-last N: also keep the N newest installed versions (default0)--older-than DUR: only remove versions whose directory is older thanDUR(Go duration, plusddays andwweeks:30m,24h,30d,12w)--dry-run: report what would be removed (the default; wins over--yes)--yes: actually remove the selected versions-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)VCENV_VERSIONVCENV_PRUNE_SCAN_ROOTS
Exit codes:
0on success (including dry runs and "nothing to prune").1if not initialized, a flag value is invalid, or removal fails.
Example:
vc-env prune # dry run
vc-env prune --keep-last 2 --yes
VCENV_PRUNE_SCAN_ROOTS="$HOME/src" vc-env prune --older-than 30d --yes
¶
vc-env prune # dry run
vc-env prune --keep-last 2 --yes
VCENV_PRUNE_SCAN_ROOTS="$HOME/src" vc-env prune --older-than 30d --yes
completion¶
Purpose: Generate a native shell completion script for vc-env.
The script completes subcommands and dynamically suggests versions:
- Installed versions for
uninstall,shell,local,global, andexec. - Cached remote versions for
installandresolve(never performs a network request; falls back to the compiled-in baseline when the cache is empty). - Shell names (
bash,zsh,fish,powershell,pwsh) forcompletion. - Flags for
doctorandprune.
Syntax:
<shell> is one of bash, zsh, fish, powershell (or its alias pwsh).
When no shell is given, it is detected from the basename of $SHELL; if that
is unset or unsupported, the bash script is printed and a note goes to stderr.
Options/flags:
--shell <shell>: same as the positional argument-h,--help: show command help and exit
Environment variables:
SHELL(read when no shell is given)VCENV_ROOT(read at completion time by the generated scripts, viavc-env __complete-versions).
Exit codes:
0on success.1if the shell is unsupported.
Install (Bash):
# Current session
source <(vc-env completion bash)
# Permanently
echo 'source <(vc-env completion bash)' >> ~/.bashrc
Install (Zsh):
# Ensure the compsys framework is loaded once in ~/.zshrc:
autoload -Uz compinit && compinit
# Current session
source <(vc-env completion zsh)
# Permanently
echo 'source <(vc-env completion zsh)' >> ~/.zshrc
Install (Fish):
# Current session
vc-env completion fish | source
# Permanently
vc-env completion fish > ~/.config/fish/completions/vc-env.fish
Install (PowerShell):
# Current session
vc-env completion powershell | Out-String | Invoke-Expression
# Permanently (append to your $PROFILE)
Add-Content -Path $PROFILE -Value 'vc-env completion pwsh | Out-String | Invoke-Expression'
Internal helper:
The generated scripts call vc-env __complete-versions {installed|remote} to list candidate versions. This command is not part of the public interface and may change at any time, but it is safe to invoke manually for debugging.
Back-compat:
vc-env autocompletion is a deprecated alias for vc-env completion and takes
the same arguments. It prints vc-env: 'autocompletion' is deprecated; use
'vc-env completion' to stderr. With no argument it now follows $SHELL
detection; existing source <(vc-env autocompletion) lines in ~/.bashrc
still get the bash script when $SHELL is bash.
resolve¶
Purpose: Resolve a version or alias to a concrete installed version and print it to stdout. Without an argument, the active version (shell > local > global) is resolved.
Used by the vcluster shim and handy in scripts.
Syntax:
See Version aliases for the supported syntax. Installed
versions are matched first; latest picks the newest installed stable
version. When nothing installed matches, the command fails, unless
--install (or VCENV_AUTO_INSTALL=1) is given: then the best remote match
is installed. Install progress goes to stderr, so stdout only ever holds the
bare version.
Options/flags:
--install: install the best remote match when nothing installed matches-s,--silent: suppress install progress output-h,--help: show command help and exit
Environment variables:
VCENV_ROOT(required)VCENV_VERSION(read when no argument is given)VCENV_AUTO_INSTALL(1implies--install)
Exit codes:
0on success.1if not initialized, no version is configured, nothing installed matches (without--install), or installing fails.
Example:
vc-env resolve # active version, e.g. 0.21.3
vc-env resolve 0.21 # e.g. 0.21.3 (highest installed 0.21.x)
vc-env resolve ~0.21.1 # e.g. 0.21.3
vc-env resolve 0.22 --install
¶
vc-env resolve # active version, e.g. 0.21.3
vc-env resolve 0.21 # e.g. 0.21.3 (highest installed 0.21.x)
vc-env resolve ~0.21.1 # e.g. 0.21.3
vc-env resolve 0.22 --install
Advanced / internal¶
These commands are kept for compatibility and scripting. They are hidden from
vc-env help and from the completion command lists.
ensure¶
Purpose: Resolve a version or alias and install the concrete version if it is
missing. Prints the concrete version to stdout. Equivalent to
vc-env resolve <version-or-alias> --install --silent.
Older shims generated by previous vc-env releases call it when
VCENV_AUTO_INSTALL=1 is set; run vc-env init (or vc-env doctor --fix) to
regenerate the shim, which now calls resolve directly.
Syntax:
Environment variables:
VCENV_ROOT(required)
Exit codes:
0on success.1on resolution failure, download failure, or checksum mismatch.
Example: