xai-org/grok-build · error · anyhow::Error

source .git must be a directory (not a linked worktree .git

Error message

source .git must be a directory (not a linked worktree .git file): {}

What it means

Error "source .git must be a directory (not a linked worktree .git file): {}" thrown in xai-org/grok-build.

Source

Thrown at crates/codegen/xai-fast-worktree/src/copy/gitdir.rs:106

/// Like [`copy_git_dir`], but keep extra `refs/remotes/origin/*` names through
/// CoW skip + post-copy sanitize so a later checkout can still see them.
pub(crate) fn copy_git_dir_keeping_origin(
    source_git: &Path,
    dest_git: &Path,
    extra_origin: &HashSet<String>,
) -> Result<GitDirCopyStats> {
    copy_git_dir_with_workers(source_git, dest_git, num_cpus::get(), extra_origin)
}

/// `copy_git_dir` with an explicit worker cap, so tests can force the parallel
/// branch (`max_workers >= 2`) deterministically regardless of `num_cpus`.
fn copy_git_dir_with_workers(
    source_git: &Path,
    dest_git: &Path,
    max_workers: usize,
    extra_origin: &HashSet<String>,
) -> Result<GitDirCopyStats> {
    anyhow::ensure!(
        source_git.is_dir(),
        "source .git must be a directory (not a linked worktree .git file): {}",
        source_git.display()
    );

    let files_copied = AtomicU64::new(0);
    let dirs_created = AtomicU64::new(0);
    let symlinks_copied = AtomicU64::new(0);
    let entries_skipped = AtomicU64::new(0);

    let filter = StandaloneCopyFilter::from_git_dir_keeping(source_git, extra_origin);

    // First pass: collect work items for parallel copy.
    // We collect all (source, dest) pairs, then process them in parallel.
    let mut work_items: Vec<CopyWork> = Vec::new();
    collect_work_recursive(
        source_git,
        dest_git,

View on GitHub (pinned to bc7f02eddd)

When it happens

Trigger: Thrown at crates/codegen/xai-fast-worktree/src/copy/gitdir.rs:106 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/3e6d9f98c7e8bb95. Report an issue: GitHub.