go: x/mobile: build failing when using go modules
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
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 40
- Comments: 77 (37 by maintainers)
Commits related to this issue
- 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... — committed to golang/mobile by bcmills 5 years ago
- 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: Ibf3b104bfaa037e1a94a5327b5a5... — committed to golang/mobile by bcmills 5 years ago
- cmd/gomobile: explicitly disable modules Gomobile doesn't support modules. Updates golang/go#27234 Change-Id: I426db1600eafd4a9ddc7eb239f5f264756f1ba35 Reviewed-on: https://go-review.googlesource.c... — committed to golang/mobile by eliasnaur 5 years ago
- Remove gomobile from CI https://github.com/golang/go/issues/27234 — committed to anacrolix/torrent by anacrolix 5 years ago
- internal/importers: replace go/build usages with go/packages This CL is a pure refactoring to replace go/build usage with golang.org/x/tools/go/packages. This is a preparation for Go modules. Update... — committed to golang/mobile by hajimehoshi 5 years ago
- cmd/gobind: fix build-tag, CGO and load trybot failures * Correctly format build tags to pass into go/packages * Removes CGO_ENABLED=0 from a packages.Load configuration * Calls go/packages.Load twic... — committed to golang/mobile by hajimehoshi 5 years ago
- bind/java, bind/objc: do not use module for reverse binding Reverse binding is not available with Go module, and some tests fail due to this. This CL suppresses the errors by disabling Go modules exp... — committed to golang/mobile by hajimehoshi 5 years ago
- cmd/gobind: replace go/build with go/packages in gen.go This is preparation to support Go module. Updates golang/go#27234 Change-Id: I8dcaed231e877e81d2072c7c85321c0acb6a8b1b Reviewed-on: https://g... — committed to golang/mobile by hajimehoshi 5 years ago
- cmd/gobind: remove go/build and go/import usages from main.go This change removes the usages of go/build and go/import, that don't work with Go module. Before this change: 1) Package information ... — committed to golang/mobile by hajimehoshi 5 years ago
- cmd/gobind: add tests enabling Go modules This CL adds tests with Go modules enabled. Updates golang/go#27234. Change-Id: I8a583c929ed9151e3b3220b4e669ff572361bb0e Reviewed-on: https://go-review.go... — committed to golang/mobile by hajimehoshi 5 years ago
- cmd/gobind: enable TestDocs tested with Go modules This CL fixes TestDocs to test with Go modules by packagestest. Updates golang/go#27234 Change-Id: I9055f52d26e494cd3b71b59d3db0755d415df356 Revie... — committed to golang/mobile by hajimehoshi 5 years ago
- cmd/gomobile: replace go/build with go/packages in bind This is a preparation to use Go modules at gomobile-bind. Updates golang/go#27234 Change-Id: I33684888b4181cc1ebd4d3c8872a6b2e62950855 Review... — committed to golang/mobile by hajimehoshi 5 years ago
- cmd/gomobile: replace go/build with go/packages in gomobile-build This is a preparation to use Go modules at gomobile command. Updates golang/go#27234 Change-Id: I8ee47cb53f5b748592a0c8c9f383abab27... — committed to golang/mobile by hajimehoshi 5 years ago
- cmd/gomobile: remove go/build usages from build.go This CL is a pure refactoring. This removes a global variable ctx, which is a build.Default. Before this change, ctx was used to keep build tags an... — committed to golang/mobile by hajimehoshi 5 years ago
- cmd/gomobile: change the working directory to $WORK/src/gobind when go-building This is a preparation to enable Go modules for gomobile commands. When Go modules is used, $GOPATH is not available. T... — committed to golang/mobile by hajimehoshi 5 years ago
- cmd/gomobile: make gomobile-init support Go modules Before this change, all the gomobile commands forced Go modules to be off internally, regardless of the current Go modules state. After this chang... — committed to golang/mobile by hajimehoshi 5 years ago
- Use go modules This won't work with gomobile, but they're working on that: https://github.com/golang/go/issues/27234 In the meantime, there's other work that can only proceed with modules. That work... — committed to google/note-maps by jtacoma 4 years ago
- cmd/gomobile: enable Go modules in gomobile-bind This CL enables Go modules in gomobile-bind command. This CL generates go.mod at $WORK/src based on the modules state of the working directory, and us... — committed to golang/mobile by hajimehoshi 5 years ago
- cmd/gomobile: remove the logic to clean the given path This CL fixes an issue that a relative path didn't work with gomobile. path.Clean removed the prefix './' and this was too aggressive. path.Clea... — committed to golang/mobile by hajimehoshi 4 years ago
- cmd/gomobile: enable Go modules at gomobile-build This CL enables Go modules at gomobile-build command. This CL is a counterpart for the change gomobile-bind: https://golang.org/cl/210380 This CL al... — committed to golang/mobile by hajimehoshi 4 years ago
Now all the problems I found have been fixed. Let’s close this issue (I don’t have the right to close this issue though), and file other issues when we find other problems.
Now gomobile-bind accepts Go modules (if the patch works correctly)! I’ll be working on gomobile-build, and we can close this issue after that.
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?
Go modules is not available yet. I’m now working on this 😃
Are there any workarounds for the meantime?
Great work @hajimehoshi !
As #33807 says, Go with modules cannot understand reverse binding imports, starting with Java or ObjC, since they are not valid FQDNs. I think it is not obvious how to solve this. My current ideas are:
I think 2. is the most feasible. 1. requires specification change and would be very controversial. @hyangah, @eliasnaur, what do you think?
CC @hyangah
As we discussed on emails, I decided to tackle this issue 😃
My current understanding is that there are three action items roughly:
The item 1. and 3. seem straight forward. 2. might be more complicated. As Hana said to me, “That conflicts with the assumption of the module-based build system and requires redesign.”. Let’s discuss about 2. later.
I’m now working on 1., but I found a problem. The reverse binding like
"Java/"or"ObjC/"doesn’t work withGO111MODULE=on: The below is one of the result.TestGobind/Java-Javapkg-WithModuleis the same test asTestGobind/Java-Javapkg, but withGO111MODULEon.I was wondering if reverse binding is still (actively) supported or not. As far as I remember, the example using reverse binding was deleted due to unsolvable circular dependencies: https://go.googlesource.com/mobile/+/2f2872eacd7fc12c252096592f87e9b23bd5be8b If we need to keep the reverse binding, I’ll do so. My concern is that reverse binding does not match with the notion of modules. If we can remove the reverse binding, I’d want to remove the reverse binding first. I tend to want to remove it, but I am not sure it’d be fine.
Any opinions?
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.
I think https://golang.org/cl/215421 will fix the issue. With this, I’ve confirmed replace directives worked.
@hajimehoshi let’s go with 2. Go with modules can understand non-url like import path but only when they are either standard packages or packages in the main module which defines the workspace.
I will take a look at 1 this week.
@balupton / @chrisprobst: I use
go mod vendorthen switchGO111MODULE=offand build it as a regular vendored project.@balupton / @chrisprobst: We basically also use
go mod vendor. However I’ve created a small tool (GoUp) which automates this process for us.@themartorana
x/mobileis a repository and a module that you can use today. It’s not shipped with Go releases, nor does it follow its release schedule. If a new version of gomobile is out, you can use it with Go 1.13.8, just like you can use it with 1.14rc1.Change https://golang.org/cl/210380 mentions this issue:
cmd/gomobile: enable Go modules at gomobile-bind@hyangah does this mean you’re still looking for a solution to allow reverse-binding? Reverse binding is a very important feature for gomobile in my opinion.