sxyazi/yazi · error

Listing Git files failed: {}

Error message

Listing Git files failed: {}

What it means

The `git ls-files --stage -z` subprocess run on the canonicalized package path exited non-zero. The spawn itself succeeded (a spawn failure yields the `Failed to list Git files` context error), so git refused to list files — usually because the directory is not a valid work tree or the index is damaged.

Source

Thrown at yazi-cli/src/package/git.rs:57

		if !output.status.success() {
			bail!("Getting revision failed: {}", output.status);
		}

		Ok(strip_trailing_newline(
			String::from_utf8(output.stdout).context("Failed to parse revision")?,
		))
	}

	async fn materialize(path: &Path) -> Result<()> {
		let path = fs::canonicalize(path).await.context("Failed to resolve Git repository")?;
		let output = Command::new("git")
			.args(["ls-files", "--stage", "-z"])
			.current_dir(&path)
			.output()
			.await
			.context("Failed to list Git files")?;
		if !output.status.success() {
			bail!("Listing Git files failed: {}", output.status);
		}

		for ent in output.stdout.split(|&c| c == 0).filter(|b| !b.is_empty()) {
			if !ent.starts_with(b"120000 ") {
				continue;
			}

			let Some(tab) = ent.iter().position(|&b| b == b'\t') else { continue };
			let link = path.join(
				Path::from_wtf8(&ent[tab + 1..]).context("Git path cannot be represented by the OS")?,
			);

			let is_symlink = fs::symlink_metadata(&link).await?.file_type().is_symlink();
			let original = if is_symlink {
				fs::read_link(&link).await? // TODO: compat for old caches, remove in the future
			} else {
				PathBuf::from_wtf8_vec(fs::read(&link).await?)
					.context("Git symlink origin cannot be represented by the OS")?

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Verify the package directory is a git checkout with an index.
  2. Run `git ls-files --stage` there manually to see the underlying git error.
  3. Delete and re-fetch the package if its repository state is broken.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at yazi-cli/src/package/git.rs:57 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02). Data as JSON: /api/errors/85f1f425dc01bc29. Report an issue: GitHub.