Skip to content

x/mobile: gobind ignores $GOROOT #18209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nikolay-turpitko opened this issue Dec 6, 2016 · 1 comment
Closed

x/mobile: gobind ignores $GOROOT #18209

nikolay-turpitko opened this issue Dec 6, 2016 · 1 comment

Comments

@nikolay-turpitko
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.7.3 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/nick/go"
GORACE=""
GOROOT="/home/nick/.local/share/umake/go/go-lang"
GOTOOLDIR="/home/nick/.local/share/umake/go/go-lang/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build692640341=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

go get golang.org/x/mobile/cmd/gobind
export ANDROID_HOME=/home/nick/Android/Sdk/
cd $GOPATH/src/golang.org/x/mobile/example/reverse/android
gradle gomobileDebug --debug

What did you expect to see?

Successful build

What did you see instead?

Build error:

13:24:54.446 [ERROR] [system.err] 2016/12/06 13:24:54 failed to go install the generated Java wrappers: exit status 2: go: cannot find GOROOT directory: /usr/local/go
...
BUILD FAILED

My current workaround

diff --git a/cmd/gobind/gen.go b/cmd/gobind/gen.go
index 8325b84..2327721 100644
--- a/cmd/gobind/gen.go
+++ b/cmd/gobind/gen.go
@@ -178,7 +178,8 @@ func genJavaPackages(ctx *build.Context, dir string, classes []*java.Class) erro
                "-pkgdir="+filepath.Join(dir, "pkg", ctx.GOOS+"_"+ctx.GOARCH),
                "Java/...",
        )
-       cmd.Env = append(cmd.Env, "GOPATH="+dir)
+       //cmd.Env = append(cmd.Env, "GOPATH="+dir)
+       cmd.Env = append(os.Environ(), "GOPATH="+dir)
        if out, err := cmd.CombinedOutput(); err != nil {
                return fmt.Errorf("failed to go install the generated Java wrappers: %v: %s", err, string(out))
        }

Then go install golang.org/x/mobile/cmd/gobind.

@rsc rsc added this to the Unreleased milestone Jan 4, 2017
@gopherbot
Copy link
Contributor

CL https://golang.org/cl/46671 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 27, 2018
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
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>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants