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: build failing when using go modules #27234

Open
mirza-s opened this issue Aug 26, 2018 · 19 comments

Comments

Projects
None yet
@mirza-s
Copy link

commented Aug 26, 2018

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

go version go1.11 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN="/Users/mbp/go/bin"
GOCACHE="/Users/mbp/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mbp/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/mbp/wrk/src/libfp/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/nt/0hzfppd92jvbk99fhvnhy8ph0000gn/T/go-build526348344=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

gomobile bind -target=android .

What did you expect to see?

Normal build as when building inside GOPATH

What did you see instead?

gomobile: go build -buildmode=c-shared -o=/var/folders/nt/0hzfppd92jvbk99fhvnhy8ph0000gn/T/gomobile-work-327189385/android/src/main/jniLibs/armeabi-v7a/libgojni.so gobind failed: exit status 1
go: finding github.com/dustin/go-humanize v0.0.0-20180713052910-9f541cc9db5d
go: finding golang.org/x/mobile v0.0.0-20180808221059-bceb7ef27cc6
can't load package: package gobind: unknown import path "gobind": cannot find module providing package gobind
@hajimehoshi

This comment has been minimized.

Copy link
Contributor

commented Sep 10, 2018

Hi, what's going on this?

@wangyun

This comment has been minimized.

Copy link

commented Sep 19, 2018

I have the same issue but with some different error message:

gomobile: /home/wangyun/dev/gopath/bin/gobind -lang=go,java -outdir=/tmp/gomobile-work-948078978 testaar failed: exit status 1
unable to import bind: cannot find package "golang.org/x/mobile/bind" in any of:
/home/wangyun/dev/software/go/src/golang.org/x/mobile/bind (from $GOROOT)
/home/wangyun/dev/gopath/src/golang.org/x/mobile/bind (from $GOPATH)
unable to import bind: cannot find package "golang.org/x/mobile/bind" in any of:
/home/wangyun/dev/software/go/src/golang.org/x/mobile/bind (from $GOROOT)
/home/wangyun/dev/gopath/src/golang.org/x/mobile/bind (from $GOPATH)
unable to import bind/java: cannot find package "golang.org/x/mobile/bind/java" in any of:
/home/wangyun/dev/software/go/src/golang.org/x/mobile/bind/java (from $GOROOT)
/home/wangyun/dev/gopath/src/golang.org/x/mobile/bind/java (from $GOPATH)

I'm using go 1.11 and updated gomobile, gobind to the latest version.

@evenardo

This comment has been minimized.

Copy link

commented Oct 10, 2018

'''
env go111module=off gomobile bind
'''
it's will temporarily worked fine

@myitcv

This comment has been minimized.

Copy link
Member

commented Nov 14, 2018

cc @eliasnaur - some time has elapsed since this issue and I'm not sufficiently up to speed to know whether mobile is now modules-aware.

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Nov 14, 2018

@glenfordwilliams

This comment has been minimized.

Copy link

commented Nov 28, 2018

is there work currently being done on this front?

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Nov 28, 2018

Not yet, at least not from my side. Partly because of time available, partly because I prefer to wait for module support to mature (GO111MODULE always on, the go/packages package feature complete and so on), but the main stumbling block is that I can't see the gomobile bind mode work as usual in module mode, at least not in its current form.
The problem is vendoring: gomobile bind generates a main package that in turn imports the packages you want to export to Java or Objective C. That works well in GOPATH mode, but not in module mode. Suppose gomobile bind in module mode generates a module containing a main package and your module as a dependency. Then, because vendored packages are only respected for the main module, any vendored packages from your module will be ignored by the go tool.
Perhaps some form of #26640 will help gomobile. Perhaps gomobile bind should work in a different way. I haven't thought that much about it.

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Nov 28, 2018

I started a conversation about gomobile and modules here: https://groups.google.com/forum/#!topic/golang-dev/C0ip7pFC2Oc

One question I would like you to ponder on that thread is whether it would be acceptable to require gomobile users to first generate glue code with the gobind tool and then only let the gomobile tool do the final packaging.

@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167180 mentions this issue: all: add go.mod

@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167179 mentions this issue: all: set GO111MODULE=off explicitly in bind tests

gopherbot pushed a commit to golang/mobile that referenced this issue Mar 13, 2019

all: set GO111MODULE=off explicitly in bind tests
Updates golang/go#27234
Updates golang/go#30228

Change-Id: Ibe281480398ff9d8c27657f399159885a75f646e
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/167179
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>

gopherbot pushed a commit to golang/mobile that referenced this issue Mar 13, 2019

all: add go.mod
Commands run:
	go mod init
	go mod edit -go=1.11
	go mod tidy
	go list -m all
	go test ./...

Updates golang/go#30228
Updates golang/go#27234

Change-Id: Ibf3b104bfaa037e1a94a5327b5a56983d9744e73
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/167180
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@gopherbot

This comment has been minimized.

Copy link

commented Mar 16, 2019

Change https://golang.org/cl/167659 mentions this issue: cmd/gomobile: explicitly disable modules

gopherbot pushed a commit to golang/mobile that referenced this issue Mar 16, 2019

cmd/gomobile: explicitly disable modules
Gomobile doesn't support modules.

Updates golang/go#27234

Change-Id: I426db1600eafd4a9ddc7eb239f5f264756f1ba35
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/167659
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@mehrvarz

This comment has been minimized.

Copy link

commented Mar 17, 2019

Hi, I use modules heavily in my projects. Unfortunately, this makes using gomobile rather difficult. When do you expect gomobile to support modules? Any updates on this?

@hajimehoshi

This comment has been minimized.

Copy link
Contributor

commented Mar 17, 2019

I was wondering whether packages that use major versions like /v2 are available with go mobile or not.

anacrolix added a commit to anacrolix/torrent that referenced this issue Mar 22, 2019

@chrisprobst

This comment has been minimized.

Copy link

commented Apr 17, 2019

We also need this feature desperately!

@balupton

This comment has been minimized.

Copy link

commented Apr 18, 2019

Are there any workarounds for the meantime?

@cryptix

This comment has been minimized.

Copy link

commented Apr 18, 2019

@balupton / @chrisprobst: I use go mod vendor then switch GO111MODULE=off and build it as a regular vendored project.

@torbenschinke

This comment has been minimized.

Copy link

commented May 7, 2019

@balupton / @chrisprobst: We basically also use go mod vendor. However I've created a small tool (GoUp) which automates this process for us.

@gopherbot

This comment has been minimized.

Copy link

commented Jun 10, 2019

Change https://golang.org/cl/181158 mentions this issue: cmd/gomobile: don't bind when not in gopath

@ChronosX88

This comment has been minimized.

Copy link

commented Jul 2, 2019

I have problem, which probably related with it - MoonSHRD/p2chat-android#2. Please, help me, if someone already solved this problem...

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