# Spin up a new worktree FAST, with cabal-buck2

> Source: <https://discourse.haskell.org/t/spin-up-a-new-worktree-fast-with-cabal-buck2/14992#post_1>
> Published: 2026-11-06 12:31:57+00:00

Something we often want to do is create a new worktree to work on a bug, PR, or small feature, especially if you’re forking off tasks for an AI to work on. Creating the worktree is easy, but to build and test the changes, you’re starting from a cold build.

I want to run through quickly how to set things up so that you can spin up a new worktree and use `cabal-buck2` to pull build artifacts from a cache, so the build in the fresh worktree is ready instantly.

Get a build cache running. I use [bazel-remote](https://github.com/buchgr/bazel-remote/releases), you can grab one of the releases or build from source. Start the cache, e.g.

```
./bazel-remote-2.6.4-linux-amd64 --dir ~/.cache/buck2 --max_size 20 --grpc_address 127.0.0.1:9092 --http_address 127.0.0.1:8080
```

Next get yourself set up with [cabal-buck2](https://hackage.haskell.org/package/cabal-buck2) - the README explains what you need.

Then set up your project with `cabal-buck2` and tell it to use the local cache:

```
cabal buck2 --enable-tests --cache=grpc://127.0.0.1:9092
```

build and run tests:

```
buck2 build //...
buck2 test //...
```

Now the build cache is warm, we can create a new worktree:

```
git worktree add /tmp/worktree -b tmp
cd buck2 && git worktree add /tmp/worktree/buck2 -b tmp
```

Run `cabal buck2` in the new worktree, again telling it to use the cache:

```
cd /tmp/worktree
cabal buck2 --enable-tests --cache=grpc://127.0.0.1:9092
```

And the build should now be almost instant:

```
buck2 build //...
```

When I tried this just now on the Cabal project itself, the clean build took 1.3s.
