cd /news/developer-tools/spin-up-a-new-worktree-fast-with-cab… · home › topics › developer-tools › article
[ARTICLE · art-165311] src=discourse.haskell.org ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

Spin up a new worktree FAST, with cabal-buck2

A developer walkthrough shows how to pair cabal-buck2 with a bazel-remote build cache so a freshly created git worktree builds almost instantly instead of from cold. The setup runs bazel-remote 2.6.4 with a 20 GB max cache size on gRPC address 127.0.0.1:9092, configures the project via `cabal buck2 --enable-tests --cache=grpc://127.0.0.1:9092`, then repeats that command in the new worktree before running `buck2 build //...`. On the Cabal project itself, the author reports the clean build in the fresh worktree took 1.3s.

read1 min views3 publishedNov 6, 2026

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, 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 - 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.

── more in #developer-tools 4 stories · sorted by recency
── more on @cabal-buck2 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/spin-up-a-new-worktr…] indexed:0 read:1min 2026-11-06 · —