zed-industries/zed · warning · ValueError

tracked changes are present. Commit or stash them, or omit…

Error message

tracked changes are present. Commit or stash them, or omit --require-clean.

What it means

With require_clean set, the source builder refuses to proceed when the computed patch is non-empty — i.e. tracked changes exist in the worktree. It is the stricter sibling of the untracked-files guard: even the patch-recording workflow (is_dirty/patch_sha256) is disallowed, and this ValueError is raised.

Solutions

  1. Stash or commit the tracked changes, then rebuild
  2. Drop --require-clean when a dirty patch is acceptable — the patch and its sha256 are recorded either way
  3. In CI, restore the worktree first: git checkout -- . or use a fresh clone
  4. Audit pre-build steps that mutate files in place

Example fix

# before
zed-eval build --require-clean   # ValueError: tracked changes are present

# after
git stash
git status --porcelain   # empty now
zed-eval build --require-clean
git stash pop
Defensive patterns

Strategy: validation

Validate before calling

import subprocess

dirty = subprocess.run(["git", "diff", "--quiet"], capture_output=True).returncode != 0
if require_clean and dirty:
    raise SystemExit("worktree has tracked changes; stash or commit before --require-clean")

Try / catch

try:
    source = build_git_patch_source(..., require_clean=True)
except ValueError as err:
    if "tracked changes" in str(err):
        subprocess.run(["git", "stash"], check=True)
        source = build_git_patch_source(..., require_clean=True)
    else:
        raise

Prevention

When it happens

Trigger: Passing --require-clean with unstaged or uncommitted tracked changes; a forgotten stash; a CI checkout contaminated by a previous step that edited files in place (formatter, codegen).

Common situations: Release or eval jobs demanding reproducible pristine builds; a formatter rewriting files before the build step; partial stash restores leaving residue.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/9f400f2aebae57a0. Report an issue: GitHub.

Appendix: source

Thrown at crates/eval_cli/zed_eval/source.py:245

    # remote (see `resolve_remote_ref`); it must be used verbatim because the
    # launcher may not have that commit fetched locally to `rev-parse`.
    if pre_resolved_base_sha:
        resolved_base_sha = pre_resolved_base_sha
    elif base_sha:
        resolved_base_sha = resolve_git_ref(base_sha)
    else:
        resolved_base_sha = current_base_sha()
    resolved_repo_url = repo_url or DEFAULT_REPO_URL
    patch = read_patch(patch_path, resolved_base_sha, clean=clean)
    patch_sha256 = sha256_text(patch) if patch.strip() else None
    untracked = [] if clean else untracked_files()
    is_dirty = bool(patch.strip())

    if untracked and not allow_untracked:
        raise ValueError(format_untracked_warning(untracked))

    if require_clean and is_dirty:
        raise ValueError(
            "tracked changes are present. Commit or stash them, or omit --require-clean."
        )

    return {
        "schema": SOURCE_SCHEMA_VERSION,
        "type": "git_patch",
        "repo_url": resolved_repo_url,
        "base_sha": resolved_base_sha,
        "base_ref": source_label or (base_sha if clean else current_ref_name()),
        "patch_sha256": patch_sha256,
        "is_dirty": is_dirty,
        "patch_path": "source.patch" if patch.strip() else None,
        "untracked_files": untracked,
        "untracked_files_included": False,
        "allow_untracked": allow_untracked,
        "require_clean": require_clean,
        "clean_source": clean,
    }, patch

View on GitHub (pinned to f4178619ac)