{"record":{"id":"f09a78fe5ca5c816","repo":"rust-lang/rust","slug":"toolchain-name-f09a78","errorCode":null,"errorMessage":"TOOLCHAIN_NAME","messagePattern":"TOOLCHAIN_NAME","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_cranelift/scripts/rustdoc-clif.rs","lineNumber":49,"sourceCode":"    if !passed_args\n        .iter()\n        .any(|arg| arg == \"--sysroot\" || arg.to_str().is_some_and(|s| s.starts_with(\"--sysroot=\")))\n    {\n        args.push(OsString::from(\"--sysroot\"));\n        args.push(OsString::from(sysroot.to_str().unwrap()));\n    }\n    if passed_args.is_empty() {\n        // Don't pass any arguments when the user didn't pass any arguments\n        // either to ensure the help message is shown.\n        args.clear();\n    }\n    args.extend(passed_args);\n\n    let rustdoc = if let Some(rustdoc) = option_env!(\"RUSTDOC\") {\n        rustdoc\n    } else {\n        // Ensure that the right toolchain is used\n        env::set_var(\"RUSTUP_TOOLCHAIN\", option_env!(\"TOOLCHAIN_NAME\").expect(\"TOOLCHAIN_NAME\"));\n        \"rustdoc\"\n    };\n\n    #[cfg(unix)]\n    panic!(\"Failed to spawn rustdoc: {}\", Command::new(rustdoc).args(args).exec());\n\n    #[cfg(not(unix))]\n    std::process::exit(\n        Command::new(rustdoc).args(args).spawn().unwrap().wait().unwrap().code().unwrap_or(1),\n    );\n}\n","sourceCodeStart":31,"sourceCodeEnd":61,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_codegen_cranelift/scripts/rustdoc-clif.rs#L31-L61","documentation":"This panic fires in the `rustdoc-clif` wrapper script for the Cranelift codegen backend. Identical in cause to [266] and [267]: `option_env!(\"TOOLCHAIN_NAME\").expect(\"TOOLCHAIN_NAME\")` at line 49. The script wraps `rustdoc` with the Cranelift backend and needs the toolchain name to pin the correct rustup toolchain via `RUSTUP_TOOLCHAIN`. If the build-time env var was absent, it panics on launch.","triggerScenarios":"Running `rustdoc-clif` when the binary was compiled without `TOOLCHAIN_NAME` in the environment. Happens when built outside the official cg_clif build system.","commonSituations":"Manually building cg_clif scripts or installing a pre-built `rustdoc-clif` that wasn't compiled with the build system's environment. Needed when generating documentation with the Cranelift codegen backend active.","solutions":["Use the official `y.rs` build system which injects `TOOLCHAIN_NAME` at compile time.","Set `TOOLCHAIN_NAME` manually before building: `TOOLCHAIN_NAME=stage2 cargo build --manifest-path scripts/Cargo.toml`.","Set the `RUSTDOC` environment variable to your rustdoc binary; the script will use it directly and skip the toolchain lookup.","Reinstall following the cg_clif README build instructions."],"exampleFix":"# before (rustdoc-clif built without TOOLCHAIN_NAME → panic)\nrustdoc-clif --version\n\n# after (set RUSTDOC to bypass)\nRUSTDOC=$(rustup which rustdoc) rustdoc-clif --version\n# or rebuild:\nTOOLCHAIN_NAME=nightly cargo build --manifest-path scripts/Cargo.toml","handlingStrategy":"validation","validationCode":"// Same as [266]/[267]: ensure TOOLCHAIN_NAME is set at build time\n// Or set RUSTDOC to bypass:\n// export RUSTDOC=$(rustup which rustdoc)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use y.rs build system for cg_clif.","Set RUSTDOC env var to bypass TOOLCHAIN_NAME.","Pin TOOLCHAIN_NAME in CI builds.","Never manually build rustdoc-clif without the build system env."],"tags":["rustc","cranelift","codegen-backend","build-config","toolchain","env-var","cg-clif","rustdoc"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}