cmd/gorebuild: leave out "you need to" suggestion

Try to make the message stand out more when it is applicable
by avoiding showing it unnecessarily when it's not.

For golang/go#60859.

Change-Id: I3085c80307650ec690afe0460bae3bdc4311616f
Reviewed-on: https://go-review.googlesource.com/c/build/+/745400
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
diff --git a/cmd/gorebuild/build.go b/cmd/gorebuild/build.go
index 480aa9b..a4bce67 100644
--- a/cmd/gorebuild/build.go
+++ b/cmd/gorebuild/build.go
@@ -174,6 +174,16 @@
 		"GO_LDFLAGS=",
 		"GO_LDSO=",
 		"PKG_CONFIG=",
+
+		// If make.bash is run and GOROOT/bin isn't already in PATH,
+		// make.bash prints what it hopes to be a useful suggestion:
+		// "*** You need to add GOROOT/bin to your PATH."
+		// Abide the suggestion and include GOROOT/bin in PATH here,
+		// so that it's not printed unnecessarily. The hope is that
+		// this way it'll stand out more when it's printed in other
+		// appropriate contexts.
+		"PATH="+filepath.Join(goroot, "bin")+string(filepath.ListSeparator)+os.Getenv("PATH"),
+		"PWD="+cmd.Dir, // set PWD to handle symlinks in work dir
 	)
 	cmd.Env = append(cmd.Env, env...)
 	log.Printf("running %s env=%v args=%v\nGOROOT=%s\nGOROOT_BOOTSTRAP=%s\n",