History

go: better logging if `go install gopls` fails (#8060)

Release Notes: - Improved logging if installing `gopls` fails

Thorsten Ball committed 2 years ago

Commit 80db4681 parent 0d2ad671 file · +10 −4Browse files

Unified · Split

crates/zed/src/languages/go.rs+10−4
@@ -125,10 +125,16 @@ impl super::LspAdapter for GoLspAdapter { · 124 unmodified lines
125125 .args(["install", "golang.org/x/tools/gopls@latest"])
126126 .output()
127127 .await?;
128− anyhow::ensure!(
129− install_output.status.success(),
130− "failed to install gopls. Is `go` installed and in the PATH?"
131− );
128+
129+ if !install_output.status.success() {
130+ log::error!(
131+ "failed to install gopls via `go install`. stdout: {:?}, stderr: {:?}",
132+ String::from_utf8_lossy(&install_output.stdout),
133+ String::from_utf8_lossy(&install_output.stderr)
134+ );
135+
136+ return Err(anyhow!("failed to install gopls with `go install`. Is `go` installed and in the PATH? Check logs for more information."));
137+ }
132138
133139 let installed_binary_path = gobin_dir.join("gopls");
134140 let version_output = process::Command::new(&installed_binary_path)