# update

Replaces the running `workrex` binary with the latest release from
[kong109/workrex](https://github.com/kong109/workrex/releases).

```bash
workrex update
```

## What happens

1. workrex asks the GitHub API for the latest release of `kong109/workrex`.
2. If that release is the installed version, workrex prints
   `Already up to date` and exits.
3. workrex downloads `workrex-<platform>.tar.gz` and its `.sha256` file, and
   checks the SHA-256 checksum.
4. workrex copies the new binary next to the old one, then renames it into
   place. If the rename fails, workrex restores the old binary.

## Platforms

Releases include binaries for macOS on Apple Silicon (`darwin-arm64`) and Linux
on x86_64 (`linux-amd64`). On any other platform, `workrex update` stops and
tells you to build from source:

```bash
cargo install --git https://github.com/kong109/workrex --bin workrex
```

workrex has no Homebrew formula. `workrex update` refuses to run when the
binary's path contains `/Cellar/` or `/homebrew/`, so keep the binary out of a
Homebrew prefix such as `/opt/homebrew/bin`.

On a remote server, the `workrex` that [`remote setup`](https://kong109.github.io/workrex/reference/commands/remote/#remote-setup)
puts on the `PATH` runs a version-pinned binary under the node root.
`workrex update` refuses to replace it, because the node runs the version that
matches your local workrex. Update workrex on your local machine, then run
`workrex remote setup <remote>` there. A pinned binary prints no update notices.
workrex counts a binary as pinned only when `setup` has marked its directory
with a `.workrex-node` file, so your own versioned install, such as
`~/.local/bin/workrex-<version>`, updates as usual.

## Update notices

Once every 24 hours at most, workrex checks for a new release in a background
process. When one exists, it prints a notice to standard error:

```
Update available: workrex v0.1.278-rex.1 -> v0.1.278-rex.3 (run `workrex update`)
```

workrex prints the notice only when standard output and standard error are
both terminals. After three notices, it waits seven days before it shows the
notice again.

To turn the check off, do one of these:

- Set `auto_update_check: false` in `~/.config/workrex/config.yaml`.
- Set the environment variable `WORKREX_NO_UPDATE_CHECK=1`.

Both settings belong to Workrex. See [Configuration](https://kong109.github.io/workrex/guide/configuration/).

## Requirements

- `curl` and `tar` on `PATH`.
- Write permission on the directory that holds the `workrex` binary.
