cmd/gobind: add GOROOT to cmd.Env from ctx.GOROOT
In two places gobind launches go commands but does not pass along the system's GOROOT causing the subprocess go's to look in /usr/local/go and fail if GOROOT is not there. Fixes golang/go#18209 Change-Id: Ica9455c0b15ba57afc5699b7757d67aa4231c508 Reviewed-on: https://go-review.googlesource.com/46671 Reviewed-by: Elias Naur <elias.naur@gmail.com>
This commit is contained in:
parent
44a54e9b78
commit
e1125eeafd
|
@ -180,7 +180,8 @@ func genJavaPackages(ctx *build.Context, dir string, classes []*java.Class, embe
|
|||
"-pkgdir="+filepath.Join(dir, "pkg", ctx.GOOS+"_"+ctx.GOARCH),
|
||||
"Java/...",
|
||||
)
|
||||
cmd.Env = append(cmd.Env, "GOPATH="+dir)
|
||||
cmd.Env = append(os.Environ(), "GOPATH="+dir)
|
||||
cmd.Env = append(cmd.Env, "GOROOT="+ctx.GOROOT)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("failed to go install the generated Java wrappers: %v: %s", err, string(out))
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ func main() {
|
|||
cmd := exec.Command("go", "install")
|
||||
cmd.Args = append(cmd.Args, flag.Args()...)
|
||||
cmd.Env = append(os.Environ(), "GOPATH="+ctx.GOPATH)
|
||||
cmd.Env = append(cmd.Env, "GOROOT="+ctx.GOROOT)
|
||||
if err := cmd.Run(); err != nil {
|
||||
// Only report I/O errors. Errors from go install is expected for as-yet
|
||||
// undefined Java wrappers.
|
||||
|
|
Loading…
Reference in New Issue