{"record":{"id":"03acf1f5a2ad1fb2","repo":"zed-industries/zed","slug":"failed-to-install-the-rust-target-target","errorCode":null,"errorMessage":"failed to install the `{RUST_TARGET}` target: {}","messagePattern":"failed to install the `(.+?)` target: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/extension/src/extension_builder.rs","lineNumber":437,"sourceCode":"            return Ok(());\n        }\n\n        anyhow::ensure!(\n            which::which(\"rustup\").is_ok(),\n            \"the `{RUST_TARGET}` target is not installed, and `rustup` is not available to \\\n             install it. Add the target to your Rust toolchain (e.g. `targets = \\\n             [\\\"{RUST_TARGET}\\\"]` for Nix rust-overlay/fenix toolchains) or install it via \\\n             your package manager\"\n        );\n\n        let output = util::command::new_command(\"rustup\")\n            .args([\"target\", \"add\", RUST_TARGET])\n            .stderr(Stdio::piped())\n            .stdout(Stdio::inherit())\n            .output()\n            .await\n            .context(\"running `rustup target add`\")?;\n        anyhow::ensure!(\n            output.status.success(),\n            \"failed to install the `{RUST_TARGET}` target: {}\",\n            String::from_utf8_lossy(&output.stderr)\n        );\n\n        Ok(())\n    }\n\n    async fn install_wasi_sdk_if_needed(&self) -> Result<PathBuf> {\n        if let Some(sdk_path) = env::var_os(\"WASI_SDK_PATH\").filter(|path| !path.is_empty()) {\n            let sdk_path = PathBuf::from(sdk_path);\n            let clang_path = wasi_sdk_clang_path(&sdk_path);\n            if fs::metadata(&clang_path).is_ok_and(|metadata| metadata.is_file()) {\n                log::info!(\"using wasi-sdk from WASI_SDK_PATH: {sdk_path:?}\");\n                return Ok(clang_path);\n            }\n            log::warn!(\n                \"WASI_SDK_PATH is set to {sdk_path:?} but clang was not found at {clang_path:?}, falling back to download\"","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/extension/src/extension_builder.rs#L419-L455","documentation":"This error is thrown by the extension builder when `rustup target add wasm32-wasip1-threads` (RUST_TARGET) exits with a non-zero status while preparing to compile a Rust extension to WebAssembly. The command's captured stderr is embedded in the message so the underlying rustup failure (network error, unknown target, missing rustup toolchain) is visible. It is a deliberate `ensure!` check after running `rustup target add` with stderr piped.","triggerScenarios":"Calling compile_rust_extension (via install_rust_wasm_target_if_needed) when the `rustup target add <RUST_TARGET>` subprocess fails: rustup is not installed or not on PATH, the target triple is not available for the installed toolchain, or the network download of the target components fails.","commonSituations":"Developers building a Zed extension without rustup installed (using only a bare rustc via distro packages); offline or behind a proxy so rustup cannot download the wasm target; an outdated rustup that does not recognize the `wasm32-wasip1-threads` target name after it was renamed from `wasm32-wasi`.","solutions":["Install rustup (https://rustup.rs) and ensure `rustup` is on your PATH.","Run `rustup target add wasm32-wasip1-threads` manually to see the full rustup error.","Update rustup with `rustup self update` if the target name is unrecognized (older rustup versions predate the wasip1-threads naming).","Check network connectivity / proxy settings if rustup fails to download the target components.","Verify the active toolchain supports the target: `rustup toolchain list` and re-add the target for the default toolchain."],"exampleFix":"// before (bare toolchain, no rustup)\n$ cargo build  # -> failed to install the `wasm32-wasip1-threads` target: ...\n\n// after\n$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n$ rustup target add wasm32-wasip1-threads\n$ cargo build","handlingStrategy":"validation","validationCode":"let ok = std::process::Command::new(\"rustup\")\n    .args([\"target\", \"list\", \"--installed\"])\n    .output()\n    .map(|o| o.status.success())\n    .unwrap_or(false);\nif !ok { eprintln!(\"rustup missing or broken; install it before building extensions\"); }","typeGuard":null,"tryCatchPattern":"match build_extension().await {\n    Err(e) if e.to_string().contains(\"failed to install the `\") => {\n        eprintln!(\"Install rustup and run `rustup target add wasm32-wasip1-threads` first: {e}\");\n    }\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["Install rustup before building Rust extensions; avoid bare distro rustc-only setups.","Pre-install the wasm target with `rustup target add wasm32-wasip1-threads` ahead of any build.","Keep rustup updated (`rustup self update`) so new target names are recognized.","Ensure stable network access to static.rust-lang.org (configure proxies accordingly)."],"tags":["rustup","wasm","toolchain","build","subprocess"],"backgroundTag":"command-not-found","analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-09-12T19:35:53.743Z","contentChangedAt":"2026-09-12T19:35:53.743Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}