[tools] gopls/internal/server: print stderr in go mod vendor error message

6 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Dec 15, 2023, 4:39:01 PM12/15/23
to Robert Findley, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Bryan Mills, golang-co...@googlegroups.com

Gopher Robot submitted this change.

View Change

Approvals: Go LUCI: TryBots succeeded Robert Findley: Automatically submit change Bryan Mills: Looks good to me, approved
gopls/internal/server: print stderr in go mod vendor error message

TestInconsistentVendoring is flaking on Windows with the not-so-helpful
"exit status 1". Include stderr in the error message to help debug.

For golang/go#64229

Change-Id: Iadb946e799e866af683ea9ea7fc039f34b45b1ba
Reviewed-on: https://go-review.googlesource.com/c/tools/+/550375
Auto-Submit: Robert Findley <rfin...@google.com>
Reviewed-by: Bryan Mills <bcm...@google.com>
LUCI-TryBot-Result: Go LUCI <golang...@luci-project-accounts.iam.gserviceaccount.com>
---
M gopls/internal/server/command.go
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gopls/internal/server/command.go b/gopls/internal/server/command.go
index 333f71c..6696585 100644
--- a/gopls/internal/server/command.go
+++ b/gopls/internal/server/command.go
@@ -386,12 +386,16 @@
// If golang/go#44119 is resolved, go mod vendor will instead modify
// modules.txt in-place. In that case we could theoretically allow this
// command to run concurrently.
+ stderr := new(bytes.Buffer)
err := deps.snapshot.RunGoCommandPiped(ctx, cache.Normal|cache.AllowNetwork, &gocommand.Invocation{
Verb: "mod",
Args: []string{"vendor"},
WorkingDir: filepath.Dir(args.URI.Path()),
- }, &bytes.Buffer{}, &bytes.Buffer{})
- return err
+ }, &bytes.Buffer{}, stderr)
+ if err != nil {
+ return fmt.Errorf("running go mod vendor failed: %v\nstderr:\n%s", err, stderr.String())
+ }
+ return nil
})
}


To view, visit change 550375. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Iadb946e799e866af683ea9ea7fc039f34b45b1ba
Gerrit-Change-Number: 550375
Gerrit-PatchSet: 2
Gerrit-Owner: Robert Findley <rfin...@google.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
Reply all
Reply to author
Forward
0 new messages