Waiting for Homebrew in the Morning, Your Coffee Gets Cold

Ever had this experience? You open your laptop in the morning, want to install a tool, type brew install xxx, and then you wait. Wait for download, wait for extraction, wait for linking. By the time your coffee gets cold, the software is still slowly installing.

It’s like going to the supermarket to buy just a bottle of water, but you have to wait in line while the person in front slowly checks out, slowly bags their items, slowly counts their change. You’re thinking: can we speed this up?

Now there’s a new tool called ZeroBrew that rewrites Homebrew’s core logic in Rust. First-time installs are 2x faster, and repeated installs can be 20x faster. Today let’s talk about why it’s so fast and how to safely try it out.

What is ZeroBrew? Why So Fast?

ZeroBrew is like a “turbocharged version” of Homebrew. It rewrites the core logic in Rust and borrows design ideas from Nix, turning package management into something super fast.

Where’s the Speed? A Supermarket Analogy

Imagine traditional Homebrew works like this: you go to the supermarket, every time you have to grab new items from the shelves, at checkout you scan items one by one, and when bagging you slowly organize everything.

ZeroBrew works like this:

The supermarket has a “smart warehouse” where every item has a unique ID (SHA-256). If you’ve bought it before, just grab it from the warehouse, no need to search the shelves again. When you “grab” items, you don’t actually grab them - you magically “copy” them, taking almost no space and super fast. Multiple checkout lanes work simultaneously, no waiting in line. Download, extraction, and linking happen at the same time, no waiting for one step to finish before starting the next.

Technical Details (For the Curious)

ZeroBrew’s core optimizations:

Packages live in /opt/zerobrew/store/{sha256}, if it already exists, reinstalling is instant. macOS copy-on-write technology (APFS clonefile), “copying” files takes almost no disk space and is extremely fast. Multiple packages download simultaneously, avoiding duplicate requests. Download, extraction, and linking happen concurrently, no wasted time. Pulls bottles from Homebrew’s CDN and reuses them.

The directory structure is also clean:

/opt/zerobrew/
├─ store/     # Content-addressed storage (SHA-256 keys)
  ├─ Cellar/ # Actual packages
  ├─ bin/    # Symlinks to executables
  └─ opt/    # Symlinks to package directories
├─ cache/     # Downloaded bottle cache
├─ db/        # SQLite database
└─ locks/     # File locks

Real-World Data: How Much Faster?

The author ran benchmarks:

PackageHomebrew TimeZeroBrew TimeSpeedup
jq5.2s2.1s2.5×
git12.8s6.3s2.0×
wget8.4s3.9s2.2×
sqlite15.6s7.8s2.0×

Repeated installs are even faster because ZeroBrew pulls directly from the store - almost instant.

You can run your own tests:

./benchmark.sh                                # Test top-100 packages
./benchmark.sh --format html -o results.html  # Generate HTML report
./benchmark.sh -c 20 --quick                  # Quick test with 22 packages

How to Safely Try It? Without Affecting Your Existing Homebrew

You might worry: my Homebrew works fine now, what if ZeroBrew breaks something?

Don’t panic, ZeroBrew and Homebrew can coexist peacefully without interfering with each other. Here’s my recommended approach.

1. Install ZeroBrew

One command does it:

curl -sSL https://raw.githubusercontent.com/lucasgelfond/zerobrew/main/install.sh | bash

After installation, run the export command it suggests (or restart your terminal).

Security note: curl | bash is convenient but opaque. If you’re concerned about security, you can download the script first to review it, or compile from source:

git clone https://github.com/lucasgelfond/zerobrew
cd zerobrew
cargo build --release
cargo install --path zb_cli

2. Try Installing a Few Common Tools

Start with a few tools you’re familiar with:

zb install jq          # Install one
zb install wget git    # Install multiple
zb uninstall jq        # Uninstall
zb reset               # Uninstall all ZeroBrew-managed packages
zb gc                  # Garbage collection, clean up unused store entries

Add this to your ~/.zshrc or ~/.bashrc:

br() {
    if zb "$@" 2>/dev/null; then
        return 0
    else
        echo "[br] zb can't handle '$*', automatically switching to brew..."
        brew "$@"
    fi
}

This way, you can use br install xxx to install software. If ZeroBrew supports it, it uses that (fast); if not, it automatically switches to Homebrew (stable).

4. Choose High-Value Packages

Not all packages are worth installing with ZeroBrew. Prioritize these: jq, git, wget, ripgrep, fd, sqlite - common development tools; tools you need to install on multiple machines; packages that perform well in benchmarks, like node, python, go.

5. Use ZeroBrew in CI/CD

If you have a macOS CI environment, ZeroBrew’s caching mechanism can save you tons of time:

# GitHub Actions example
- name: Cache ZeroBrew store
  uses: actions/cache@v3
  with:
    path: /opt/zerobrew/store
    key: zerobrew-${{ hashFiles('**/Brewfile') }}

- name: Install dependencies
  run: zb install jq git wget ripgrep fd

Run zb gc regularly to control cache size.

Migration and Recovery: What If Something Goes Wrong?

Start by installing 5-10 packages you’re familiar with, see how it goes. Confirm these packages work normally. If no issues, expand to more packages.

If you want to stop using it, uninstalling is simple:

zb reset                  # Uninstall all ZeroBrew-managed packages
sudo rm -rf /opt/zerobrew # Delete ZeroBrew directory
hash -r                   # Clear shell command cache

Everything ZeroBrew does is in /opt/zerobrew, just delete it and it won’t affect Homebrew.

Both ZeroBrew and Homebrew link executables to /usr/local/bin. If you want to prioritize one, make sure it’s first in your $PATH:

# Prioritize ZeroBrew
export PATH="/opt/zerobrew/store/bin:$PATH"

# Or use the br() function above for automatic fallback

Currently ZeroBrew mainly supports core command-line tools. For GUI apps (Casks) and non-core Taps, continue using Homebrew. For core CLI tools, use ZeroBrew.

When Should You Keep Using Homebrew?

ZeroBrew is fast, but not a silver bullet. Keep using Homebrew in these cases: you depend on non-core Taps or obscure formulas; your workflow deeply relies on Homebrew internals (like custom taps, formula development); you need to manage lots of GUI apps (Casks).

The good news is ZeroBrew and Homebrew can coexist, taking the best of both.

A Few Practical Tips

ZeroBrew’s store will grow over time, clean it up regularly:

zb gc  # Clean up unused store entries

You can set up a cron job to clean automatically every week:

# Every Sunday at 2 AM
0 2 * * 0 /usr/local/bin/zb gc

Write your common tools into a script for one-click recovery when switching machines:

#!/bin/bash
# bootstrap.sh
set -euo pipefail

packages=(jq git wget ripgrep fd sqlite node python go)
zb install "${packages[@]}"

echo "Development environment restored!"

Want to know how much ZeroBrew speeds up your toolchain? Run a test:

./benchmark.sh -c 20 --quick
open results.html

Common Pitfalls and Solutions

zb install xxx errors, saying formula not found. ZeroBrew currently mainly supports core formulas, some obscure ones might not be supported yet. Use the br() function above to automatically fall back to Homebrew.

After installing ZeroBrew, some commands still use the Homebrew version. Homebrew’s path is first in $PATH. Adjust $PATH to put ZeroBrew’s path first:

export PATH="/opt/zerobrew/store/bin:$PATH"

/opt/zerobrew/store keeps growing. ZeroBrew caches all packages you’ve installed. Run zb gc regularly to clean up.

Summary

ZeroBrew rewrites Homebrew’s core logic in Rust, 2-20x faster. Coexists with Homebrew, prioritize ZeroBrew for common tools, continue using Homebrew for obscure ones. Core technologies are content-addressed storage, APFS clonefile, parallel downloads, and streaming processing.

Next Steps

Install ZeroBrew: curl -sSL https://raw.githubusercontent.com/lucasgelfond/zerobrew/main/install.sh | bash

Try installing a few common tools: zb install jq git wget

Set up the smart fallback function (see above)

Run a benchmark to see the speedup

Try it in CI/CD, cache the store directory

Cheatsheet

# Install ZeroBrew
curl -sSL https://raw.githubusercontent.com/lucasgelfond/zerobrew/main/install.sh | bash

# Basic operations
zb install jq          # Install
zb uninstall jq        # Uninstall
zb reset               # Uninstall all
zb gc                  # Garbage collection

# Smart fallback function (add to ~/.zshrc)
br() {
    if zb "$@" 2>/dev/null; then
        return 0
    else
        echo "[br] zb can't handle '$*', automatically switching to brew..."
        brew "$@"
    fi
}

# Benchmark
./benchmark.sh -c 20 --quick
open results.html

Did You Find This Article Useful?

If you’ve also been tortured by Homebrew’s speed, or you’re interested in ZeroBrew, give it a try.

What tools do you most commonly install with Homebrew? Which one installs the slowest? Feel free to chat in the comments.

If this article helped you, give it a like so more people can see this speed-boosting tool, or share it with friends who might need it. Follow Dream Beast Programming to not miss more practical development tools and tips.

Your support is my biggest motivation to keep creating!