sxyazi/yazi · error · anyhow::Error

bundled rust-lld setup requires a Unix host

Error message

bundled rust-lld setup requires a Unix host

What it means

yazi-build sets up the toolchain's bundled rust-lld by symlinking it into target/.rust-lld (ld.lld plus per-target aliases) and prepending that directory to PATH for linking. The symlink uses std::os::unix::fs::symlink; under cfg(not(unix)) the setup bails with "bundled rust-lld setup requires a Unix host" instead of attempting a Unix-only operation on Windows.

Source

Thrown at yazi-build/src/build.rs:63

		if is_windows_target(&self.target) { "release-windows" } else { "release" }
	}

	fn expose_lld(&self, cmd: &mut Command) -> Result<()> {
		let rust_lld = Self::rustc_libdir()?
			.parent()
			.context("Rust target libdir has no parent")?
			.join("bin/rust-lld");
		ensure!(rust_lld.is_file(), "{} does not exist", rust_lld.display());

		let temp_dir = workspace_root()?.join("target/.rust-lld");
		fs::create_dir_all(&temp_dir).context("failed to create `target/.rust-lld` directory")?;
		for name in ["ld.lld".to_owned()].into_iter().chain(self.lld_alias()) {
			let link = temp_dir.join(name);
			ok_or_not_found!(fs::remove_file(&link));
			#[cfg(unix)]
			std::os::unix::fs::symlink(&rust_lld, link)?;
			#[cfg(not(unix))]
			anyhow::bail!("bundled rust-lld setup requires a Unix host");
		}

		let path = env::var_os("PATH").unwrap_or_default();
		cmd.env("PATH", env::join_paths(iter::once(temp_dir).chain(env::split_paths(&path)))?);
		Ok(())
	}

	fn rustc_libdir() -> Result<PathBuf> {
		let output = Command::new(env::var_os("RUSTC").unwrap_or_else(|| "rustc".into()))
			.args(["--print", "target-libdir"])
			.output()
			.context("failed to locate the Rust target libdir")?;

		ensure!(output.status.success(), "`rustc --print target-libdir` failed");
		Ok(String::from_utf8(output.stdout)?.trim().into())
	}

	// Cross GCC resolves `-fuse-ld=lld` as `<toolchain-prefix>ld.lld`.

View on GitHub (pinned to 94abcfa92f)

Solutions

  1. Build on a Unix host (Linux/macOS/WSL)
  2. On Windows, link with the platform default linker (MSVC/MinGW) and do not enable the bundled rust-lld path
  3. Cross-compile Windows artifacts from Unix via scripts/build.sh with a windows target
Defensive patterns

Strategy: validation

Validate before calling

// Gate the lld setup on the host before opting in:
if cfg!(not(unix)) {
    // skip bundled rust-lld and use the platform default linker
    return configure_default_linker(cmd);
}

Type guard

fn lld_setup_supported() -> bool { cfg!(unix) }

Prevention

When it happens

Trigger: Running the yazi build/packaging path that enables bundled rust-lld on a Windows host — the symlink branch simply does not exist there, so the build aborts by design.

Common situations: Building or packaging yazi natively on Windows; CI matrices that forget to skip the lld setup on Windows runners.

Related errors


AI-assisted analysis of sxyazi/yazi@94abcfa92f (2026-08-16). Data as JSON: /api/errors/f2d0b6e149a8cfc8. Report an issue: GitHub.