{"slug": "spin-up-a-new-worktree-fast-with-cabal-buck2", "title": "Spin up a new worktree FAST, with cabal-buck2", "summary": "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.", "body_md": "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.\n\nI 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.\n\nGet 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.\n\n```\n./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\n```\n\nNext get yourself set up with [cabal-buck2](https://hackage.haskell.org/package/cabal-buck2) - the README explains what you need.\n\nThen set up your project with `cabal-buck2` and tell it to use the local cache:\n\n```\ncabal buck2 --enable-tests --cache=grpc://127.0.0.1:9092\n```\n\nbuild and run tests:\n\n```\nbuck2 build //...\nbuck2 test //...\n```\n\nNow the build cache is warm, we can create a new worktree:\n\n```\ngit worktree add /tmp/worktree -b tmp\ncd buck2 && git worktree add /tmp/worktree/buck2 -b tmp\n```\n\nRun `cabal buck2` in the new worktree, again telling it to use the cache:\n\n```\ncd /tmp/worktree\ncabal buck2 --enable-tests --cache=grpc://127.0.0.1:9092\n```\n\nAnd the build should now be almost instant:\n\n```\nbuck2 build //...\n```\n\nWhen I tried this just now on the Cabal project itself, the clean build took 1.3s.", "url": "https://wpnews.pro/news/spin-up-a-new-worktree-fast-with-cabal-buck2", "canonical_source": "https://discourse.haskell.org/t/spin-up-a-new-worktree-fast-with-cabal-buck2/14992#post_1", "published_at": "2026-11-06 12:31:57+00:00", "updated_at": "2026-11-06 12:49:22.745563+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents"], "entities": ["cabal-buck2", "bazel-remote", "Buck2", "Cabal", "Git"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/spin-up-a-new-worktree-fast-with-cabal-buck2", "markdown": "https://wpnews.pro/news/spin-up-a-new-worktree-fast-with-cabal-buck2.md", "text": "https://wpnews.pro/news/spin-up-a-new-worktree-fast-with-cabal-buck2.txt", "jsonld": "https://wpnews.pro/news/spin-up-a-new-worktree-fast-with-cabal-buck2.jsonld"}}