{"record":{"id":"f2d0b6e149a8cfc8","repo":"sxyazi/yazi","slug":"bundled-rust-lld-setup-requires-a-unix-host","errorCode":null,"errorMessage":"bundled rust-lld setup requires a Unix host","messagePattern":"bundled rust-lld setup requires a Unix host","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"yazi-build/src/build.rs","lineNumber":63,"sourceCode":"\t\tif is_windows_target(&self.target) { \"release-windows\" } else { \"release\" }\n\t}\n\n\tfn expose_lld(&self, cmd: &mut Command) -> Result<()> {\n\t\tlet rust_lld = Self::rustc_libdir()?\n\t\t\t.parent()\n\t\t\t.context(\"Rust target libdir has no parent\")?\n\t\t\t.join(\"bin/rust-lld\");\n\t\tensure!(rust_lld.is_file(), \"{} does not exist\", rust_lld.display());\n\n\t\tlet temp_dir = workspace_root()?.join(\"target/.rust-lld\");\n\t\tfs::create_dir_all(&temp_dir).context(\"failed to create `target/.rust-lld` directory\")?;\n\t\tfor name in [\"ld.lld\".to_owned()].into_iter().chain(self.lld_alias()) {\n\t\t\tlet link = temp_dir.join(name);\n\t\t\tok_or_not_found!(fs::remove_file(&link));\n\t\t\t#[cfg(unix)]\n\t\t\tstd::os::unix::fs::symlink(&rust_lld, link)?;\n\t\t\t#[cfg(not(unix))]\n\t\t\tanyhow::bail!(\"bundled rust-lld setup requires a Unix host\");\n\t\t}\n\n\t\tlet path = env::var_os(\"PATH\").unwrap_or_default();\n\t\tcmd.env(\"PATH\", env::join_paths(iter::once(temp_dir).chain(env::split_paths(&path)))?);\n\t\tOk(())\n\t}\n\n\tfn rustc_libdir() -> Result<PathBuf> {\n\t\tlet output = Command::new(env::var_os(\"RUSTC\").unwrap_or_else(|| \"rustc\".into()))\n\t\t\t.args([\"--print\", \"target-libdir\"])\n\t\t\t.output()\n\t\t\t.context(\"failed to locate the Rust target libdir\")?;\n\n\t\tensure!(output.status.success(), \"`rustc --print target-libdir` failed\");\n\t\tOk(String::from_utf8(output.stdout)?.trim().into())\n\t}\n\n\t// Cross GCC resolves `-fuse-ld=lld` as `<toolchain-prefix>ld.lld`.","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/sxyazi/yazi/blob/94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2/yazi-build/src/build.rs#L45-L81","documentation":"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.","triggerScenarios":"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.","commonSituations":"Building or packaging yazi natively on Windows; CI matrices that forget to skip the lld setup on Windows runners.","solutions":["Build on a Unix host (Linux/macOS/WSL)","On Windows, link with the platform default linker (MSVC/MinGW) and do not enable the bundled rust-lld path","Cross-compile Windows artifacts from Unix via scripts/build.sh with a windows target"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Gate the lld setup on the host before opting in:\nif cfg!(not(unix)) {\n    // skip bundled rust-lld and use the platform default linker\n    return configure_default_linker(cmd);\n}","typeGuard":"fn lld_setup_supported() -> bool { cfg!(unix) }","tryCatchPattern":null,"preventionTips":["Treat bundled rust-lld as a Unix-only path","Use WSL or Linux CI runners for lld-linked builds","Cross-compile Windows artifacts from a Unix host"],"tags":["build","linker","rust-lld","platform","windows"],"backgroundTag":null,"analyzedSha":"94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2","analyzedAt":"2026-08-16T09:56:24.836Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}