The zb gc command performs garbage collection by removing store entries that are no longer referenced by any installed packages.
Usage
Description
Zerobrew uses a content-addressed store to manage package files. When packages are uninstalled or upgraded, old versions may remain in the store. The garbage collector identifies and removes these unreferenced entries to free up disk space.
This command is safe to run at any time - it will only remove store entries that are no longer needed by any installed package.
How It Works
- Scans all currently installed packages
- Identifies which store entries are referenced
- Removes any store entries that aren’t referenced by installed packages
- Reports which entries were removed
Examples
Run garbage collection:
Run garbage collection after uninstalling packages:
zb uninstall node python
zb gc
Output
When unreferenced entries are found and removed:
==> Running garbage collection...
✓ Removed a1b2c3d4e5f6
✓ Removed f6e5d4c3b2a1
✓ Removed 9876543210ab
==> Removed 3 store entries
When no unreferenced entries exist:
==> Running garbage collection...
No unreferenced store entries to remove.
When to Use
Run garbage collection to free up disk space after:
- Uninstalling packages
- Upgrading packages (old versions remain until gc)
- Failed installations that left partial store entries
- Resetting or cleaning up your zerobrew installation
Garbage collection is automatically safe - it will never remove store entries that are still in use by installed packages.
The garbage collection process is typically fast, even with many installed packages. The command:
- Only removes entries that are definitively unreferenced
- Uses efficient graph traversal to identify orphaned entries
- Operates directly on the filesystem without requiring network access
- zb uninstall - Uninstall packages (often followed by gc)
- zb reset - Reset entire zerobrew installation
- zb list - List installed packages