{"record":{"id":"6c293dbc8b826e60","repo":"zed-industries/zed","slug":"the-rust-target-target-is-not-installed-and-rustup-is-not","errorCode":null,"errorMessage":"the `{RUST_TARGET}` target is not installed, and `rustup` is not available to install it. Add the target to your Rust toolchain (e.g. `targets = [\"{RUST_TARGET}\"]` for Nix rust-overlay/fenix toolchains) or install it via your package manager","messagePattern":"the `(.+?)` target is not installed, and `rustup` is not available to install it\\. Add the target to your Rust toolchain \\(e\\.g\\. `targets = \\[\"(.+?)\"\\]` for Nix rust-overlay/fenix toolchains\\) or install it via your package manager","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/extension/src/extension_builder.rs","lineNumber":422,"sourceCode":"\n    async fn install_rust_wasm_target_if_needed(&self) -> Result<()> {\n        let rustc_output = util::command::new_command(\"rustc\")\n            .args([\"--print\", \"target-libdir\", \"--target\", RUST_TARGET])\n            .output()\n            .await\n            .context(\"running rustc\")?;\n        anyhow::ensure!(\n            rustc_output.status.success(),\n            \"failed to retrieve the `{RUST_TARGET}` target libdir: {}\",\n            String::from_utf8_lossy(&rustc_output.stderr)\n        );\n\n        let target_libdir = PathBuf::from(String::from_utf8(rustc_output.stdout)?.trim());\n        if target_libdir.exists() {\n            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)","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/extension/src/extension_builder.rs#L404-L440","documentation":"Raised in `install_rust_wasm_target_if_needed` (crates/extension/src/extension_builder.rs:422) when the wasm target's libdir (from `rustc --print target-libdir --target wasm32-wasip1`) does not exist on disk — meaning the target's standard library is not installed — AND no `rustup` binary can be found on PATH to install it automatically. The builder cannot compile the extension to wasm and gives guidance for toolchains that don't use rustup (e.g. Nix).","triggerScenarios":"Calling `compile_rust_extension` -> `install_rust_wasm_target_if_needed` where `rustc --target wasm32-wasip1` succeeds but the printed target-libdir path doesn't exist, and `which::which(\"rustup\")` fails. This is exactly the situation of non-rustup toolchains: system rustc packages, Nix rust-overlay/fenix without `targets = [\"wasm32-wasip1\"]`, or Homebrew/Handheld toolchain installs without the wasm stdlib component.","commonSituations":"Building a Zed extension on NixOS with a fenix/rust-overlay toolchain lacking the wasm32-wasip1 target; using Debian/Ubuntu's rustc package which doesn't ship the wasm wasi stdlib; a minimal Docker image with rustc but no rustup; PATH where rustup exists but is not visible to the spawned process.","solutions":["If using rustup (or able to install it), run `rustup target add wasm32-wasip1`, or install rustup so Zed's builder can auto-install the target.","For Nix rust-overlay/fenix toolchains, add `targets = [\"wasm32-wasip1\"]` to the toolchain definition and rebuild the dev shell.","For distro-packaged Rust, install the wasm target package if available (e.g. `rust-std-wasm32-wasip1` / `rust-src`-style extras) or switch to a rustup-managed toolchain.","Verify the target is present: `rustc --print target-libdir --target wasm32-wasip1` should print a path that exists (`ls <path>`)."],"exampleFix":"// before (flake.nix): fenix toolchain without the wasm target\nrustToolchain = fenix.stable.toolchain;\n\n// after\nrustToolchain = fenix.stable.toolchain.override {\n  targets = [ \"wasm32-wasip1\" ];\n};","handlingStrategy":"validation","validationCode":"# shell: ensure the wasm stdlib is actually installed before building\nlibdir=$(rustc --print target-libdir --target wasm32-wasip1)\n[ -d \"$libdir\" ] || { echo \"wasm32-wasip1 stdlib missing; run: rustup target add wasm32-wasip1 (or add targets=[\\\"wasm32-wasip1\\\"] in Nix)\"; exit 1; }","typeGuard":null,"tryCatchPattern":"try {\n  await buildExtension(path);\n} catch (err) {\n  if (String(err).includes(\"target is not installed\") && String(err).includes(\"rustup\")) {\n    console.error(\"Install the wasm target manually: `rustup target add wasm32-wasip1`, or add targets = [\\\"wasm32-wasip1\\\"] to your Nix toolchain.\");\n  }\n  throw err;\n}","preventionTips":["Add the wasm32-wasip1 target to your toolchain definition (Nix: targets = [\"wasm32-wasip1\"]) rather than relying on runtime rustup installation.","Install rustup in environments that build extensions so the target can be auto-installed.","Validate during environment setup that `rustc --print target-libdir --target wasm32-wasip1` points to an existing directory.","Pin the toolchain (rust-toolchain.toml) with the wasm target included across the team."],"tags":["rust","toolchain","wasm","nix","missing-target"],"backgroundTag":"missing-dependency","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"}