# Quickstart

Install canibump, write your first blocker and watch it turn bumpable.

## Install

Pick one.

- `cargo install canibump`
- `nix profile install github:mlavrinenko/canibump`
- A prebuilt binary from the [releases page](https://github.com/mlavrinenko/canibump/releases/latest)

`canibump completions <shell>` prints tab completion for your shell. The Nix package installs it for bash, zsh and fish.

## Write a blocker

Say you patched libfoo because it crashes on empty input, and the fix is PR #412 upstream. Put a `canibump.toml` next to your code.

`canibump.toml`

```toml
#:schema https://raw.githubusercontent.com/mlavrinenko/canibump/main/schema/canibump.schema.json

[[blocker]]
id = "libfoo-crash"
note = "drop the libfoo crash patch"
state = "github:libfoo/libfoo#412"

[scan]
paths = ["**/*.nix"]
```

A blocker has an `id`, a `note` that says what to undo, and one condition. `state` waits for an issue or PR to close the right way. `[scan]` lists the files canibump reads to find your workarounds. The `#:schema` line is optional, and gives you completion and typo squiggles in any editor with taplo or tombi.

## Mark the workaround

Drop a `canibump:<id>` comment right next to the patch.

`pkgs/libfoo.nix`

```nix
{ libfoo }:

libfoo.overrideAttrs (old: {
  # canibump:libfoo-crash
  patches = (old.patches or [ ]) ++ [ ./fix-crash-on-empty-input.patch ];
})
```

The marker tells canibump where the workaround lives, so you never write a file name or a line number into the note.

## Run it

```
$ canibump
waiting   libfoo-crash  github:libfoo/libfoo#412 is open
```

The PR is still open, so the blocker is `waiting` and the run exits `0`. Run it again and it reuses this result for a while, with no request. [Read results offline](https://mlavrinenko.github.io/canibump/read-results-offline/index.md) says how long.

## When upstream lands

A week later the PR merges. `--refresh` checks everything right away instead of trusting the cache.

```
$ canibump --refresh
bumpable  libfoo-crash  github:libfoo/libfoo#412 merged (drop the libfoo crash patch)
          at pkgs/libfoo.nix:4
```

This time it’s `bumpable`, with the marked line under it, and the run exits `9`. Drop the patch, then the blocker.

## Next

- [Run it in CI](https://mlavrinenko.github.io/canibump/run-in-ci/index.md) so you hear about it without asking.
- [Wait for a fix to ship](https://mlavrinenko.github.io/canibump/wait-on-a-release/index.md) when merged isn’t enough and you need the release.
- [Catch forgotten workarounds](https://mlavrinenko.github.io/canibump/catch-forgotten-workarounds/index.md) that never got a blocker.
