sxyazi/yazi · error
Due to Cargo's limitations, Yazi on crates.io must be built…
Error message
Due to Cargo's limitations, Yazi on crates.io must be built with `cargo install --force yazi-build`
What it means
This panic fires in yazi-cli's build script when Cargo compiles the crate from a git checkout or from the crates.io registry source directory. Yazi's build scripts generate code that requires the `yazi-build` wrapper, which Cargo's plain `cargo install yazi-cli` flow cannot provide correctly. The panic exists to stop users from producing broken builds.
Solutions
- Run `cargo install --force yazi-build` and then `cargo install --force --path <yazi-cli-dir> yazi-cli` from a cloned source tree instead of plain `cargo install yazi-cli`.
- Prefer a prebuilt binary or package-manager distribution of Yazi over compiling from crates.io.
- If building from source, clone the repo and build locally so the manifest path does not match the checkouts/registry patterns.
Example fix
// before cargo install yazi-cli // after cargo install --force yazi-build git clone https://github.com/sxyazi/yazi && cd yazi cargo install --force --path yazi-cli
Defensive patterns
Strategy: validation
Validate before calling
# shell check before install manifest_dir=$(pwd) case "$manifest_dir" in */git/checkouts/yazi-*|*/registry/src/index.crates.io-*) echo "must use yazi-build"; exit 1;; esac
Prevention
- Never use plain `cargo install yazi-cli`; always go through `cargo install --force yazi-build` or prebuilt binaries.
- Avoid depending on yazi crates directly from git URLs.
- Read the crates.io README build instructions before installing.
When it happens
Trigger: Running `cargo install yazi-cli` (which fetches from crates.io registry src) or depending on yazi from a git URL, causing CARGO_MANIFEST_DIR to contain `/git/checkouts/yazi-` or `/registry/src/index.crates.io-`.
Common situations: Users installing `ya` with plain `cargo install yazi-cli` after reading crates.io docs; projects adding yazi-cli as a git dependency; building from a vendored registry copy.
Related errors
- Due to Cargo's limitations, Yazi on crates.io must be built…
- exited with status
- failed to determine the Cargo bin directory
- Failed to get asset directory
- Failed to get cache directory
AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02).
Data as JSON: /api/errors/7579f296f3887eb6.
Report an issue: GitHub.
Appendix: source
Thrown at yazi-cli/build.rs:14
#[path = "src/args.rs"]
mod args;
use std::{env, error::Error};
use clap::CommandFactory;
use clap_complete::{Shell, generate_to};
fn main() -> Result<(), Box<dyn Error>> {
let manifest = env::var_os("CARGO_MANIFEST_DIR").unwrap().to_string_lossy().replace(r"\", "/");
if manifest.contains("/git/checkouts/yazi-")
|| manifest.contains("/registry/src/index.crates.io-")
{
panic!(
"Due to Cargo's limitations, Yazi on crates.io must be built with `cargo install --force yazi-build`"
);
}
generate()
}
fn generate() -> Result<(), Box<dyn Error>> {
if env::var_os("YAZI_GEN_COMPLETIONS").is_none() {
return Ok(());
}
let cmd = &mut args::Args::command();
let bin = "ya";
let out = "completions";
std::fs::create_dir_all(out)?;
for sh in [Shell::Bash, Shell::Fish, Shell::Zsh, Shell::Elvish, Shell::PowerShell] {View on GitHub (pinned to 5f901b886b)