Skip to main content
Skip to main content

b update

Update binaries and sync env files. If no arguments are given, b updates all binaries and envs from the b.yaml configuration file.

Alias​

  • u

Usage​

b update [binary|env...] [flags]

Examples​

Update all binaries and envs​

If a b.yaml file is present, this command will update all binaries to their latest versions and re-sync all env files.

b update

Update a specific binary​

Update a single binary to its latest version.

b update jq

Update a specific env​

Pass the exact env key that b env status prints — including SSH (git@…) keys and #label refs. The key round-trips as-is:

b update github.com/org/infra
b update git@github.com:org/infra#main

A ref like github.com/org/infra is a valid env key and a valid binary provider ref. When it is configured as an env, b resolves it to the env. To force env resolution explicitly — useful for label-less keys, or when the same ref exists as both a binary and an env — append a #:

b update github.com/org/infra#

The # is safe unquoted as long as there is no space before it (name#label, name#). A space before # starts a shell comment.

With the # marker you can also use a short handle — the repo name, or org/repo — instead of the full key. b matches it against the trailing segments of your configured env keys:

# both target an env keyed git@github.com:org/infra#main
b update infra#
b update org/infra#

If a short handle matches more than one env, b lists the candidates and asks you to use the fuller key.

If you type the plain https path of an SSH-keyed env (e.g. github.com/org/infra for an env keyed git@github.com:org/infra), b updates it as an ad-hoc binary and prints a hint pointing at the env. To target the env instead, paste the exact key b env status prints, or use a short handle (org/infra#) — appending # to the https path won't match, since the SSH key has no host segment.

Scope: envs only / binaries only​

Refresh vendored env content without touching the toolchain, or vice versa:

# Sync every env, skip binaries
b update --envs-only

# Update every binary, skip env sync
b update --binaries-only

Force an update​

Force an update even if the binary is already at the latest version. This is useful for re-installing a corrupted binary.

b update --force kubectl

Update with merge strategy​

Use the --strategy flag to control how env file updates handle local changes:

# Replace local files with upstream (default)
b update --strategy=replace

# Keep local files, only add new ones
b update --strategy=client

# Three-way merge: upstream changes + local changes
b update --strategy=merge

Merge strategies​

StrategyDescription
replaceOverwrite local files with upstream content (default)
clientKeep local files unchanged; only add new files from upstream
mergeThree-way merge using the lock file as a common ancestor. Detects conflicts and prompts for resolution

When using merge, b computes a three-way diff between:

  1. The base version (from b.lock — last known good state)
  2. The upstream version (latest from the remote repo)
  3. The local version (your current file on disk)

If both upstream and local have changed the same region, a conflict marker is inserted and the user is prompted to resolve it.

Env conflict warnings​

When multiple env entries write to the same destination path, b warns about potential conflicts before syncing:

⚠ Conflict: config.yaml is written by both github.com/org/infra (base/config.yaml)
and github.com/org/overrides (override/config.yaml)
Hint: use 'dest' or 'ignore' in b.yaml to resolve

Dry-run​

Preview what would change without writing files or updating the lock:

b update --dry-run

Rollback​

Revert envs to their previous commit (from b.lock):

b update --rollback github.com/org/infra

Group filtering​

Only update envs tagged with a specific group. Groups are an env-only concept, so --group implies --envs-only — binaries are left untouched:

b update --group=dev

Post-update hooks​

Binaries configured with an onPost hook in b.yaml will run that hook after a successful update — the same way it runs after b install. The hook only fires when the on-disk binary actually changed (not on digest-match skips or --dry-run).

binaries:
github.com/arg-sh/argsh:
onPost: argsh builtin ${B_EVENT} # B_EVENT=update

See b install — Post-install hooks for the full list of environment variables and examples.

Failed downloads​

When the download of a binary fails, b update keeps the old binary and continues with the other binaries and the envs. Then it stops with an error that names each binary whose download failed (exit code 1), as b install does. When an env also fails, the error names both.

Flags​

FlagDescription
--strategyMerge strategy for env updates: replace, client, or merge
--dry-runShow what would change without writing files
--rollbackRollback envs to their previous commit from lock
--groupOnly update envs in this group (implies --envs-only)
--envs-onlyOnly update envs, skip binaries
--binaries-onlyOnly update binaries, skip envs
-h, --helphelp for update

Global Flags​

FlagDescription
-c, --config stringPath to configuration file (current: /home/fentas/github/fentas/b/.bin/b.yaml)
--forceForce operations, overwriting existing binaries
-q, --quietQuiet mode
-v, --versionPrint version information and quit
Was this section helpful?