Skip to content

Commit f201e0c

Browse files
committed
fix: sometimes GOBIN doesn't work
1 parent 964852e commit f201e0c

File tree

1 file changed

+16
-2
lines changed
  • internal/extension-registry/installer/impl/goinstaller

1 file changed

+16
-2
lines changed

Diff for: internal/extension-registry/installer/impl/goinstaller/installer.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ func goInstallTo(pkg, version string, dst string, showProgress bool) error {
5858

5959
cmd := exec.Command("go", "install", pkgWithVersion)
6060

61-
cmd.Env = []string{"GOBIN=" + d}
62-
cmd.Env = append(cmd.Env, os.Environ()...)
61+
cmd.Env = append(copyEnvWithoutGOBIN(), "GOBIN="+d)
6362

6463
if showProgress {
6564
pp.Println("go install", pkgWithVersion, "...")
@@ -106,3 +105,18 @@ func goGetBinNameForPkg(pkg string) string {
106105

107106
return name
108107
}
108+
109+
func copyEnvWithoutGOBIN() []string {
110+
env := os.Environ()
111+
copied := make([]string, 0, len(env))
112+
113+
for _, e := range env {
114+
if strings.HasPrefix(e, "GOBIN=") {
115+
continue
116+
}
117+
118+
copied = append(copied, e)
119+
}
120+
121+
return copied
122+
}

0 commit comments

Comments
 (0)