zed-industries/zed · error
the `{RUST_TARGET}` target is not installed, and `rustup` is
Error message
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 What it means
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).
Source
Thrown at crates/extension/src/extension_builder.rs:422
async fn install_rust_wasm_target_if_needed(&self) -> Result<()> {
let rustc_output = util::command::new_command("rustc")
.args(["--print", "target-libdir", "--target", RUST_TARGET])
.output()
.await
.context("running rustc")?;
anyhow::ensure!(
rustc_output.status.success(),
"failed to retrieve the `{RUST_TARGET}` target libdir: {}",
String::from_utf8_lossy(&rustc_output.stderr)
);
let target_libdir = PathBuf::from(String::from_utf8(rustc_output.stdout)?.trim());
if target_libdir.exists() {
return Ok(());
}
anyhow::ensure!(
which::which("rustup").is_ok(),
"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"
);
let output = util::command::new_command("rustup")
.args(["target", "add", RUST_TARGET])
.stderr(Stdio::piped())
.stdout(Stdio::inherit())
.output()
.await
.context("running `rustup target add`")?;
anyhow::ensure!(
output.status.success(),
"failed to install the `{RUST_TARGET}` target: {}",
String::from_utf8_lossy(&output.stderr)View on GitHub (pinned to 9d272b0363)
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>`).
Example fix
// before (flake.nix): fenix toolchain without the wasm target
rustToolchain = fenix.stable.toolchain;
// after
rustToolchain = fenix.stable.toolchain.override {
targets = [ "wasm32-wasip1" ];
}; Defensive patterns
Strategy: validation
Validate before calling
# shell: ensure the wasm stdlib is actually installed before building
libdir=$(rustc --print target-libdir --target wasm32-wasip1)
[ -d "$libdir" ] || { echo "wasm32-wasip1 stdlib missing; run: rustup target add wasm32-wasip1 (or add targets=[\"wasm32-wasip1\"] in Nix)"; exit 1; } Try / catch
try {
await buildExtension(path);
} catch (err) {
if (String(err).includes("target is not installed") && String(err).includes("rustup")) {
console.error("Install the wasm target manually: `rustup target add wasm32-wasip1`, or add targets = [\"wasm32-wasip1\"] to your Nix toolchain.");
}
throw err;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- failed to retrieve the `{RUST_TARGET}` target libdir: {}
- failed to install dlv via `go install`. stdout: {:?}, stderr
- failed to build extension {}
- failed to install the `{RUST_TARGET}` target: {}
- in #[action] attribute: {}
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-09-12).
Data as JSON: /api/errors/6c293dbc8b826e60.
Report an issue: GitHub.