zed-industries/zed · error

failed to install dlv via `go install`. stdout: {:?}, stderr

Error message

failed to install dlv via `go install`. stdout: {:?}, stderr: {:?}
 Please try installing it manually using 'go install github.com/go-delve/delve/cmd/dlv@latest'

What it means

The Go adapter's fallback installer: after locating a go binary via which(), it runs `go install github.com/go-delve/delve/cmd/dlv@latest` with GOBIN pointed at Zed's debug-adapters directory. If the command's exit status is unsuccessful, Zed bails with both captured stdout and stderr plus a hint to install dlv manually. The message tells you go exists but the module install itself failed.

Source

Thrown at crates/dap_adapters/src/go.rs:474

        } else if delegate.fs().is_file(&dlv_path).await {
            dlv_path.to_string_lossy().into_owned()
        } else {
            let go = delegate
                .which(OsStr::new("go"))
                .await
                .context("Go not found in path. Please install Go first, then Dlv will be installed automatically.")?;

            let adapter_path = paths::debug_adapters_dir().join(&Self::ADAPTER_NAME);

            let install_output = util::command::new_command(&go)
                .env("GO111MODULE", "on")
                .env("GOBIN", &adapter_path)
                .args(&["install", "github.com/go-delve/delve/cmd/dlv@latest"])
                .output()
                .await?;

            if !install_output.status.success() {
                bail!(
                    "failed to install dlv via `go install`. stdout: {:?}, stderr: {:?}\n Please try installing it manually using 'go install github.com/go-delve/delve/cmd/dlv@latest'",
                    String::from_utf8_lossy(&install_output.stdout),
                    String::from_utf8_lossy(&install_output.stderr)
                );
            }

            adapter_path
                .join(&dlv_binary)
                .to_string_lossy()
                .into_owned()
        };

        let cwd = Some(
            task_definition
                .config
                .get("cwd")
                .and_then(|s| s.as_str())
                .map(PathBuf::from)

View on GitHub (pinned to f4178619ac)

Solutions

  1. Read the embedded stderr - it is the actual go build/module error
  2. Install manually as the message suggests: `go install github.com/go-delve/delve/cmd/dlv@latest`, then place dlv where the adapter expects it
  3. Upgrade Go if stderr shows syntax/build errors from an old toolchain
  4. Fix module fetching: check GOPROXY/GOFLAGS/GOSUMDB and network egress to proxy.golang.org

Example fix

// before: rely on Zed's automatic install
// (fails with 'failed to install dlv via `go install`')

// after: install manually and point Zed at it
go install github.com/go-delve/delve/cmd/dlv@latest
# then in Zed's Go debug adapter settings set the binary path, e.g.:
# "go": { "binary": { "path": "$(go env GOPATH)/bin/dlv" } }
Defensive patterns

Strategy: fallback

Validate before calling

// Check dlv presence first; skip the auto-installer entirely when present
let dlv = paths::debug_adapters_dir().join("go/dlv");
if !dlv.exists() {
    ensure_network_to("proxy.golang.org:443").await?;
    ensure_go_version_at_least("1.21").await?;
}

Try / catch

match install_dlv_via_go(/* .. */).await {
    Ok(path) => Ok(path),
    Err(err) if err.to_string().contains("failed to install dlv") => {
        // fall back to a user-installed dlv on PATH
        which::which("dlv").map_err(|e| err.context(e.to_string()))
    }
    Err(err) => Err(err),
}

Prevention

When it happens

Trigger: First Go debug session on a machine with Go installed but module download broken: no network / blocked GOPROXY, go version too old for @latest delve (build errors in stderr), GONOSUMDB/GOSUMDB verification failures, GOFLAGS injecting conflicting flags, or permission problems writing to the GOBIN directory.

Common situations: Corporate networks blocking proxy.golang.org; ancient Go toolchains (delve needs recent Go); GOPROXY=off or private-module configs; read-only or full disk for the adapters dir; SELinux/apparmor denying exec-write in the install dir.

Related errors


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