{"record":{"id":"7579f296f3887eb6","repo":"sxyazi/yazi","slug":"due-to-cargo-s-limitations-yazi-on-crates-io-must","errorCode":null,"errorMessage":"Due to Cargo's limitations, Yazi on crates.io must be built with `cargo install --force yazi-build`","messagePattern":"Due to Cargo's limitations, Yazi on crates\\.io must be built with `cargo install --force yazi-build`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-cli/build.rs","lineNumber":14,"sourceCode":"#[path = \"src/args.rs\"]\nmod args;\n\nuse std::{env, error::Error};\n\nuse clap::CommandFactory;\nuse clap_complete::{Shell, generate_to};\n\nfn main() -> Result<(), Box<dyn Error>> {\n\tlet manifest = env::var_os(\"CARGO_MANIFEST_DIR\").unwrap().to_string_lossy().replace(r\"\\\", \"/\");\n\tif manifest.contains(\"/git/checkouts/yazi-\")\n\t\t|| manifest.contains(\"/registry/src/index.crates.io-\")\n\t{\n\t\tpanic!(\n\t\t\t\"Due to Cargo's limitations, Yazi on crates.io must be built with `cargo install --force yazi-build`\"\n\t\t);\n\t}\n\n\tgenerate()\n}\n\nfn generate() -> Result<(), Box<dyn Error>> {\n\tif env::var_os(\"YAZI_GEN_COMPLETIONS\").is_none() {\n\t\treturn Ok(());\n\t}\n\n\tlet cmd = &mut args::Args::command();\n\tlet bin = \"ya\";\n\tlet out = \"completions\";\n\n\tstd::fs::create_dir_all(out)?;\n\tfor sh in [Shell::Bash, Shell::Fish, Shell::Zsh, Shell::Elvish, Shell::PowerShell] {","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-cli/build.rs#L1-L32","documentation":"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.","triggerScenarios":"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-`.","commonSituations":"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.","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."],"exampleFix":"// before\ncargo install yazi-cli\n\n// after\ncargo install --force yazi-build\ngit clone https://github.com/sxyazi/yazi && cd yazi\ncargo install --force --path yazi-cli","handlingStrategy":"validation","validationCode":"# shell check before install\nmanifest_dir=$(pwd)\ncase \"$manifest_dir\" in\n  */git/checkouts/yazi-*|*/registry/src/index.crates.io-*) echo \"must use yazi-build\"; exit 1;;\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["build-script","cargo","panic","install"],"backgroundTag":"cargo-registry-build-unsupported","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}