zed-industries/zed · error

Cargo command failed

Error message

Cargo command failed

What it means

The cargo debug locator spawned the user's build command (with --message-format=json) to find the binary, and the process exited non-zero or its JSON output yielded no runnable target. The underlying cargo failure is the root cause; the error is raised in the locator's run method.

Source

Thrown at crates/project/src/debugger/locators/cargo.rs:148

                    .args
                    .iter()
                    .cloned()
                    .take_while(|arg| arg != "--")
                    .chain(Some("--message-format=json".to_owned()))
                    .collect::<Vec<_>>(),
            )
            .envs(build_config.env.iter().map(|(k, v)| (k.clone(), v.clone())))
            .current_dir(cwd)
            .stdout(SmolStdio::piped())
            .spawn()?;

        let mut output = String::new();
        if let Some(mut stdout) = child.stdout.take() {
            stdout.read_to_string(&mut output).await?;
        }

        let status = child.status().await?;
        anyhow::ensure!(status.success(), "Cargo command failed");

        let is_test = build_config
            .args
            .first()
            .is_some_and(|arg| arg == "test" || arg == "t");

        let is_ignored = build_config.args.contains(&"--include-ignored".to_owned());

        let executables = output
            .lines()
            .filter(|line| !line.trim().is_empty())
            .filter_map(|line| serde_json::from_str(line).ok())
            .filter(|json: &Value| {
                let is_test_binary = json
                    .get("profile")
                    .and_then(|profile| profile.get("test"))
                    .and_then(Value::as_bool)
                    .unwrap_or(false);

View on GitHub (pinned to f4178619ac)

Solutions

  1. Run the same cargo build command manually to see the compile error and fix it
  2. Verify the build command, target, and features in the debug scenario
  3. Ensure cargo emits JSON messages (the locator appends --message-format=json) and the binary target actually gets built
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/project/src/debugger/locators/cargo.rs:148 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/d0dc7333d67b6e7f. Report an issue: GitHub.