Skip to main content
bach update brings bach itself up to date. When a newer release exists on GitHub, bach also says so at the end of a command run in a terminal, so you know to run it.

The update notice

When a newer release is out, the end of a command shows:
The notice never makes a command wait. A background bach update-refresh asks GitHub (or, for a copy installed with npm, the npm registry, so the notice never announces a version npm doesn’t have yet) every time you run a command (not again within 10 seconds; a check that fails, offline for example, is forgotten) and keeps the answer in a small file in Bach’s cache folder (update-check.json, see Files and locations). A command only reads that file, so the first run after a release says nothing and the next one does. It is shown only when a person is looking, and never when:
  • standard error is not a terminal (a pipe, a log file),
  • you pass --json,
  • the CI environment variable is set,
  • BACH_NO_UPDATE_CHECK is set to any value (see Environment variables),
  • this bach was built from a checkout of the source (target\debug or target\release).
bach update and bach update --check always look at GitHub themselves, and update the file the notice reads.

How bach is replaced

1

Find the release

bach asks GitHub for the newest release, or the tag you named. It takes only the tag and the file names from the answer and builds the download address itself, under https://github.com/usebach/bach/releases/download.
2

Download and check

The archive for your system and its .sha256 go to a staging folder next to bach. If the SHA-256 doesn’t match, nothing is changed.
3

Try the new program

The archive is unpacked and the new bach must start and report the version that was asked for.
4

Swap

bach and the bach-setup.exe beside it are replaced. Each old file is kept until all new ones are in place, and put back if a step fails. Windows can’t delete a running program, so bach.exe.old is removed the next time bach starts.

Installed with a package manager

Only a copy made of loose files (the release download, install.ps1 or install.sh) replaces itself. A copy that another tool manages is that tool’s to update, so bach update stops and names the command instead. The notice shows the same command. For npm, bach update --check and the notice compare with the newest version on npm, not on GitHub. If npm prints npm warn install-scripts lines during the update, they are about your other global packages. @usebach/cli has no install script. A system-wide install in %ProgramFiles%\bach-cli needs administrator rights to be replaced. Run bach update from an administrator terminal, or run install.ps1 again with BACH_SCOPE set to system.

Machine-readable output

With --json, standard output is one JSON object. It holds current (this bach), latest (the release looked at), update_available, install (standalone, npm, scoop, winget, cargo or checkout) and, unless --check was given, updated.

Errors