Skip to content

Commit ab17da2

Browse files
author
Bryan C. Mills
committed
internal/version: update PWD in the environment for commands that set Dir
Updates golang/go#50599. Change-Id: I5702de0d6e23fa2ae1a03b0f47464170d4b691c0 Reviewed-on: https://go-review.googlesource.com/c/dl/+/380503 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 1eec607 commit ab17da2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/version/gotip.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ func installTip(root, target string) error {
5757
cmd.Stdout = os.Stdout
5858
cmd.Stderr = os.Stderr
5959
cmd.Dir = root
60+
cmd.Env = dedupEnv(caseInsensitiveEnv, append(os.Environ(), "PWD="+cmd.Dir))
6061
return cmd.Run()
6162
}
6263
gitOutput := func(args ...string) ([]byte, error) {
6364
cmd := exec.Command("git", args...)
6465
cmd.Dir = root
66+
cmd.Env = dedupEnv(caseInsensitiveEnv, append(os.Environ(), "PWD="+cmd.Dir))
6567
return cmd.Output()
6668
}
6769

@@ -154,7 +156,11 @@ func installTip(root, target string) error {
154156
return fmt.Errorf("failed to detect an existing go installation for bootstrap: %v", err)
155157
}
156158
cmd.Env = append(os.Environ(), "GOROOT_BOOTSTRAP="+strings.TrimSpace(string(goroot)))
159+
} else {
160+
cmd.Env = os.Environ()
157161
}
162+
cmd.Env = dedupEnv(caseInsensitiveEnv, append(cmd.Env, "PWD="+cmd.Dir))
163+
158164
if err := cmd.Run(); err != nil {
159165
return fmt.Errorf("failed to build go: %v", err)
160166
}

0 commit comments

Comments
 (0)