Skip to content

zrebuild - Force Complete Rebuild with Validation

Performs a comprehensive three-phase rebuild: syntax validation of all source files, clean removal of all compiled bytecode, and fresh recompilation from scratch.

Overview

zrebuild is stricter than zr. It validates every .zsh file for syntax errors before touching any compiled output, removes all existing .zwc files to ensure a clean slate, and then runs zprime --quiet to recompile everything. If any syntax error is found, the process stops immediately without deleting or recompiling anything.

When to use: When zr produces unexpected results, after pulling large changesets, or when you suspect corrupted bytecode.

Usage

zrebuild

Options

  • -h, --help: Show help message

Examples

# Force complete rebuild with validation
zrebuild

# After completion, reload the shell
exec zsh

What It Does

  1. Phase 1 — Syntax validation: Runs zsh -n on every .zsh file in all framework directories plus build/ and lib/rebuild/. Stops immediately if any file has syntax errors.
  2. Phase 2 — Clean bytecode: Removes all .zwc files and generated -all.zsh concatenations from .compiled/ directories. Also removes stray .zwc files up to 2 levels deep.
  3. Phase 3 — Recompilation: Loads core/02_vars.zsh and core/06_engine.zsh to bootstrap zprime, then runs zprime --quiet for a fresh build.

Dependencies

  • Required: zsh (for zsh -n syntax checking), zprime (compilation engine)
  • Required: core/02_vars.zsh, core/06_engine.zsh

See Also

  • zr — Standard incremental rebuild (faster, less thorough)
  • zfresh — Clean rebuild with automatic shell restart
  • zrecompile — Selective recompilation by scope