> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Bach builds Windows installers from one bach.toml with the bach command: bach init, bach check, bach preview, bach build. Installs are per user and need no administrator rights by default. installer.scope = "machine" installs for every user after one Windows prompt. On Windows, run setup files with Start-Process -Wait -PassThru in PowerShell, and give signtool arguments that start with the word sign.

# How updates work

> Understand both kinds of Bach updates, what is kept or removed, what happens when something fails, and what you publish for automatic updates.

Bach can update an installed app in two ways: a user runs a newer setup file, or the app fetches new versions by itself. Both install the same way. This page explains what happens on the user's computer, and points to the guides for setting up automatic updates.

## Two ways to update

**Running a newer setup file.** This always works, with nothing to configure. You raise the version, build, and give people the new file. See [Ship your first update](/docs/guides/first-update.md).

**Automatic updates.** With an `[updates]` section, the installed app checks a small file on your website or GitHub releases, downloads newer versions in the background and installs them when the app is closed. See [Set up automatic updates](/docs/guides/automatic-updates.md).

## What happens during an update

Setup finds the old installation by the app's [id](/docs/guides/write-bach-toml.md#the-id-keep-it-stable) and updates it in place:

* It installs into the same folder, even if you've changed the default since.
* It keeps the user's choices: shortcuts, start with Windows, `PATH` and components. Options that are new in this version start at their defaults.
* It adds and replaces files, and removes files that the old version installed but the new one doesn't have.
* It doesn't touch user data or files your app created.
* A file the user changed after install is kept if the new version no longer ships it.

If the app is running, the window offers **Close and continue**. Bach asks the app to close the way Windows does when it shuts down, so the app can ask to save first. It doesn't force it to quit. A silent update stops with exit code 1 instead.

## If an update fails

Updates are all or nothing. Setup first unpacks every new file next to the old one, then swaps them all in. If a file is locked, the disk is full, or a later step such as a [run step](/docs/guides/run-programs.md) fails, the old files, the old uninstaller and the old shortcuts are put back, and the version under Settings › Apps doesn't change. What a program you ran already did on its own, such as changing a database, isn't undone.

If the computer loses power in the middle, setup keeps a small journal in the install folder. The next setup, update or uninstall first puts the old files back.

## Older versions

Running an older setup file over a newer installation shows a warning, and the user has to choose **Install anyway**. A silent install refuses, unless you add `--allow-downgrade`. Automatic updates never go back to an older version.

## What automatic updates need from you

With each release you publish two files to a place with a fixed address:

1. the setup file
2. `latest.json`, the **update feed**: a small file that says which version is newest, where to download it and what its checksum is

`bach build` writes both when `[updates]` is configured. With GitHub releases, one release workflow does the publishing for you. Any web host that can serve two files over `https` works too. See [Where to host updates](/docs/guides/update-hosting.md).

## Related guides

* [Set up automatic updates](/docs/guides/automatic-updates.md)
* [Where to host updates](/docs/guides/update-hosting.md)
* [Protect your updates](/docs/guides/update-security.md): signed feeds and signed files
* [Patches and staged rollouts](/docs/guides/patches-and-rollouts.md): smaller downloads and gradual releases
* [Automatic updates not working?](/docs/troubleshooting/updates.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.