-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
What did you do?
$ git clone https://go.googlesource.com/go $HOME/gotip
$ cd $HOME/gotip/src
src $ ./make.bash
What did you expect to see?
src $ ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.15.4 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/amd64.
---
Installed Go for darwin/amd64 in /Users/gopher/gotip
Installed commands in /Users/gopher/gotip/bin
*** You need to add /Users/gopher/gotip/bin to your PATH.
What did you see instead?
src $ ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.15.4 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/amd64.
---
Installed Go for darwin/amd64 in /Users/gopher/gotip
Installed commands in /Users/gopher/gotip/bin
Note the "*** You need to add /Users/gopher/gotip/bin to your PATH." line is missing.
That line is important because if it isn't done, and there happens to be another go
binary in PATH (quite likely for Go developers), the wrong go
binary will be used.
Cause
make.bash
includes these lines:
# -e doesn't propagate out of eval, so check success by hand.
eval $(./cmd/dist/dist env -p || echo FAIL=true)
if [ "$FAIL" = true ]; then
exit 1
fi
dist env -p
includes a modified version of PATH in its output, which is then eval
ed.
The banner is printed afterwards with a check for whether PATH contains GOROOT/bin:
if !strings.Contains(pathsep+os.Getenv("PATH")+pathsep, pathsep+gobin+pathsep) {
xprintf("*** You need to add %s to your PATH.\n", gobin)
}
Where os.Getenv("PATH")
ends up containing gobin
, but only because make.bash
added it temporarily.
As far as I can tell, this same problem affected all.bash
8 years ago in #3699, and it was fixed in CL 6272048 and CL 6525049, so this is a matter of resolving this for when make.bash
(or make.bat, make.rc) is invoked directly.