Skip to content

Commit

Permalink
[release-branch.go1.16] build: set GOPATH consistently in run.bash, r…
Browse files Browse the repository at this point in the history
…un.bat, run.rc

We used to clear GOPATH in all the build scripts.
Clearing GOPATH is misleading at best, since you just end up
with the default GOPATH (%USERPROFILE%\go on Windows).
Unless that's your GOROOT, in which case you end up with a
fatal error from the go command (#43938).

run.bash changed to setting GOPATH=/dev/null, which has no
clear analogue on Windows.

run.rc still clears GOPATH.

Change them all to set GOPATH to a non-existent directory
/nonexist-gopath or c:\nonexist-gopath.

For #45238.
Fixes #45240.

Change-Id: I51edd66d37ff6a891b0d0541d91ecba97fbbb03d
Reviewed-on: https://go-review.googlesource.com/c/go/+/288818
Trust: Russ Cox <[email protected]>
Trust: Jason A. Donenfeld <[email protected]>
Reviewed-by: Cherry Zhang <[email protected]>
Reviewed-by: Alex Brainman <[email protected]>
Reviewed-by: Jason A. Donenfeld <[email protected]>
(cherry picked from commit bb6efb9)
Reviewed-on: https://go-review.googlesource.com/c/go/+/304772
Run-TryBot: Dmitri Shuralyov <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Alexander Rakoczy <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
Trust: Carlos Amedee <[email protected]>
  • Loading branch information
rsc authored and dmitshur committed Mar 29, 2021
1 parent 9c7463c commit 1d967ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
10 changes: 1 addition & 9 deletions src/run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,7 @@ fi

eval $(../bin/go env)
export GOROOT # The api test requires GOROOT to be set, so set it to match ../bin/go.

# We disallow local import for non-local packages, if $GOROOT happens
# to be under $GOPATH, then some tests below will fail. $GOPATH needs
# to be set to a non-empty string, else Go will set a default value
# that may also conflict with $GOROOT. The $GOPATH value doesn't need
# to point to an actual directory, it just needs to pass the semantic
# checks performed by Go. Use $GOROOT to define $GOPATH so that we
# don't blunder into a user-defined symbolic link.
export GOPATH=/dev/null
export GOPATH=/nonexist-gopath

unset CDPATH # in case user has it set
export GOBIN=$GOROOT/bin # Issue 14340
Expand Down
4 changes: 1 addition & 3 deletions src/run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ setlocal

set GOBUILDFAIL=0

:: we disallow local import for non-local packages, if %GOROOT% happens
:: to be under %GOPATH%, then some tests below will fail
set GOPATH=
set GOPATH=c:\nonexist-gopath
:: Issue 14340: ignore GOBIN during all.bat.
set GOBIN=
set GOFLAGS=
Expand Down
9 changes: 4 additions & 5 deletions src/run.rc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ if(! test -f ../bin/go){

eval `{../bin/go env}
GOPATH = () # we disallow local import for non-local packages, if $GOROOT happens
# to be under $GOPATH, then some tests below will fail
GOBIN = () # Issue 14340
GOFLAGS = ()
GO111MODULE = ()
GOPATH=/nonexist-gopath
GOBIN=() # Issue 14340
GOFLAGS=()
GO111MODULE=()
exec ../bin/go tool dist test -rebuild $*

0 comments on commit 1d967ab

Please sign in to comment.