Skip to content

Commit 1d967ab

Browse files
rscdmitshur
authored andcommitted
[release-branch.go1.16] build: set GOPATH consistently in run.bash, run.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]>
1 parent 9c7463c commit 1d967ab

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

src/run.bash

+1-9
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,7 @@ fi
2323

2424
eval $(../bin/go env)
2525
export GOROOT # The api test requires GOROOT to be set, so set it to match ../bin/go.
26-
27-
# We disallow local import for non-local packages, if $GOROOT happens
28-
# to be under $GOPATH, then some tests below will fail. $GOPATH needs
29-
# to be set to a non-empty string, else Go will set a default value
30-
# that may also conflict with $GOROOT. The $GOPATH value doesn't need
31-
# to point to an actual directory, it just needs to pass the semantic
32-
# checks performed by Go. Use $GOROOT to define $GOPATH so that we
33-
# don't blunder into a user-defined symbolic link.
34-
export GOPATH=/dev/null
26+
export GOPATH=/nonexist-gopath
3527

3628
unset CDPATH # in case user has it set
3729
export GOBIN=$GOROOT/bin # Issue 14340

src/run.bat

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ setlocal
1818

1919
set GOBUILDFAIL=0
2020

21-
:: we disallow local import for non-local packages, if %GOROOT% happens
22-
:: to be under %GOPATH%, then some tests below will fail
23-
set GOPATH=
21+
set GOPATH=c:\nonexist-gopath
2422
:: Issue 14340: ignore GOBIN during all.bat.
2523
set GOBIN=
2624
set GOFLAGS=

src/run.rc

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ if(! test -f ../bin/go){
1212

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

0 commit comments

Comments
 (0)