Skip to content
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

x/mobile: gobind ignores $GOROOT #18209

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

Comments

Projects
None yet
3 participants
@nikolay-turpitko
Copy link

commented Dec 6, 2016

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

This comment has been minimized.

Copy link

commented Jun 26, 2017

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

@golang golang locked and limited conversation to collaborators Jun 27, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.