-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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 #37048
Comments
Thank you for the report @axet! Kindly cc-ing @bcmills @jayconrod. |
What version of the |
Recent: axet@axet-laptop:~$ gomobile version |
I probably know what is going on, If I init gomobile staying inside my library with "go.mod" directory it will fail. Doesn't matter where gomobile is located, only $PWD is matter.
And now it bugged. Maybe it is not a bug, but error message a bit confusing. |
cc @hyangah |
It looks like the original file has
and
cc @hajimehoshi |
Change https://golang.org/cl/218057 mentions this issue: |
One thing to watch out for: it's not generally safe to use module directories in the module cache as replacements. Replacement modules must have a |
It is closed, but still failed to compile. Same library I build using old style GOPATH no problems, go.mod build failed with two errors, first run:
second run (same command: gomobile bind)
Should I create separate issue? |
@axet Please do. You can refer to this issue if any of the information here is relevant. Thanks. |
Change https://golang.org/cl/226279 mentions this issue: |
Before this change, the main module specifies the module version of the package to bind, the version might not be adopted by gomobile because gomobile trims some dependencies information. If a dependency is not a main module nor a replaced module, the dependency information is omitted. For example, if you have this go.mod in a workspace: module example.com/m requier ( github.com/foo/bar v0.1.0-123456 ) and then run `gomobile bind github.com/foo/bar` there, the specified version might not be used because github.com/foo/bar is not a main nor a replaced module. This change keeps the dependency information as much as possible to avoid this confusion. Updates golang/go#37048 Change-Id: I875a1b9485438bdee336f3fc2d131775353004f5 Reviewed-on: https://go-review.googlesource.com/c/mobile/+/226279 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Previously, gomobile bind's go.mod generation logic assumed replacing module was always located in the disk, but is not always true. It's valid to replace a module(version) with another module&version. For example, replace golang.org/x/tools => ../ causes: { "Path": "golang.org/x/tools", "Version": "v0.0.0-20191017151554-a3bc800455d5", "Replace": { "Path": "../", "Dir": "/usr/local/google/home/hakim/go/src/golang.org/x/tools", "GoMod": "/usr/local/google/home/hakim/go/src/golang.org/x/tools/go.mod", "GoVersion": "1.11" }, "Dir": "/usr/local/google/home/hakim/go/src/golang.org/x/tools", "GoMod": "/usr/local/google/home/hakim/go/src/golang.org/x/tools/go.mod", "GoVersion": "1.11" } replace github.com/anacrolix/torrent v1.13.0 => gitlab.com/axet/torrent v0.0.0-20200205141541-92b4b9e7387e causes: { "Path": "github.com/anacrolix/torrent", "Version": "v1.13.0", "Replace": { "Path": "gitlab.com/axet/torrent", "Version": "v0.0.0-20200205141541-92b4b9e7387e", "Time": "2020-02-05T14:15:41Z", "Dir": "/usr/local/google/home/hakim/go/pkg/mod/gitlab.com/axet/torrent@v0.0.0-20200205141541-92b4b9e7387e", "GoMod": "/usr/local/google/home/hakim/go/pkg/mod/cache/download/gitlab.com/axet/torrent/@v/v0.0.0-20200205141541-92b4b9e7387e.mod" }, "Dir": "/usr/local/google/home/hakim/go/pkg/mod/gitlab.com/axet/torrent@v0.0.0-20200205141541-92b4b9e7387e", "GoMod": "/usr/local/google/home/hakim/go/pkg/mod/cache/download/gitlab.com/axet/torrent/@v/v0.0.0-20200205141541-92b4b9e7387e.mod" } Also, while we are here, trim down the entries added to the generated go.mod. We need the main module, and the replaced module info. We may want to pin golang.org/x/mobile version if possible, but I don't know a reliable way to achieve that yet. Fixes golang/go#37048 Change-Id: Ibd7332338c0a3c4165a642c3e86852061f6ab13b Reviewed-on: https://go-review.googlesource.com/c/mobile/+/218057 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Before this change, the main module specifies the module version of the package to bind, the version might not be adopted by gomobile because gomobile trims some dependencies information. If a dependency is not a main module nor a replaced module, the dependency information is omitted. For example, if you have this go.mod in a workspace: module example.com/m requier ( github.com/foo/bar v0.1.0-123456 ) and then run `gomobile bind github.com/foo/bar` there, the specified version might not be used because github.com/foo/bar is not a main nor a replaced module. This change keeps the dependency information as much as possible to avoid this confusion. Updates golang/go#37048 Change-Id: I875a1b9485438bdee336f3fc2d131775353004f5 Reviewed-on: https://go-review.googlesource.com/c/mobile/+/226279 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Previously, gomobile bind's go.mod generation logic assumed replacing module was always located in the disk, but is not always true. It's valid to replace a module(version) with another module&version. For example, replace golang.org/x/tools => ../ causes: { "Path": "golang.org/x/tools", "Version": "v0.0.0-20191017151554-a3bc800455d5", "Replace": { "Path": "../", "Dir": "/usr/local/google/home/hakim/go/src/golang.org/x/tools", "GoMod": "/usr/local/google/home/hakim/go/src/golang.org/x/tools/go.mod", "GoVersion": "1.11" }, "Dir": "/usr/local/google/home/hakim/go/src/golang.org/x/tools", "GoMod": "/usr/local/google/home/hakim/go/src/golang.org/x/tools/go.mod", "GoVersion": "1.11" } replace github.com/anacrolix/torrent v1.13.0 => gitlab.com/axet/torrent v0.0.0-20200205141541-92b4b9e7387e causes: { "Path": "github.com/anacrolix/torrent", "Version": "v1.13.0", "Replace": { "Path": "gitlab.com/axet/torrent", "Version": "v0.0.0-20200205141541-92b4b9e7387e", "Time": "2020-02-05T14:15:41Z", "Dir": "/usr/local/google/home/hakim/go/pkg/mod/gitlab.com/axet/torrent@v0.0.0-20200205141541-92b4b9e7387e", "GoMod": "/usr/local/google/home/hakim/go/pkg/mod/cache/download/gitlab.com/axet/torrent/@v/v0.0.0-20200205141541-92b4b9e7387e.mod" }, "Dir": "/usr/local/google/home/hakim/go/pkg/mod/gitlab.com/axet/torrent@v0.0.0-20200205141541-92b4b9e7387e", "GoMod": "/usr/local/google/home/hakim/go/pkg/mod/cache/download/gitlab.com/axet/torrent/@v/v0.0.0-20200205141541-92b4b9e7387e.mod" } Also, while we are here, trim down the entries added to the generated go.mod. We need the main module, and the replaced module info. We may want to pin golang.org/x/mobile version if possible, but I don't know a reliable way to achieve that yet. Fixes golang/go#37048 Change-Id: Ibd7332338c0a3c4165a642c3e86852061f6ab13b Reviewed-on: https://go-review.googlesource.com/c/mobile/+/218057 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Previously, gomobile bind's go.mod generation logic assumed replacing module was always located in the disk, but is not always true. It's valid to replace a module(version) with another module&version. For example, replace golang.org/x/tools => ../ causes: { "Path": "golang.org/x/tools", "Version": "v0.0.0-20191017151554-a3bc800455d5", "Replace": { "Path": "../", "Dir": "/usr/local/google/home/hakim/go/src/golang.org/x/tools", "GoMod": "/usr/local/google/home/hakim/go/src/golang.org/x/tools/go.mod", "GoVersion": "1.11" }, "Dir": "/usr/local/google/home/hakim/go/src/golang.org/x/tools", "GoMod": "/usr/local/google/home/hakim/go/src/golang.org/x/tools/go.mod", "GoVersion": "1.11" } replace github.com/anacrolix/torrent v1.13.0 => gitlab.com/axet/torrent v0.0.0-20200205141541-92b4b9e7387e causes: { "Path": "github.com/anacrolix/torrent", "Version": "v1.13.0", "Replace": { "Path": "gitlab.com/axet/torrent", "Version": "v0.0.0-20200205141541-92b4b9e7387e", "Time": "2020-02-05T14:15:41Z", "Dir": "/usr/local/google/home/hakim/go/pkg/mod/gitlab.com/axet/torrent@v0.0.0-20200205141541-92b4b9e7387e", "GoMod": "/usr/local/google/home/hakim/go/pkg/mod/cache/download/gitlab.com/axet/torrent/@v/v0.0.0-20200205141541-92b4b9e7387e.mod" }, "Dir": "/usr/local/google/home/hakim/go/pkg/mod/gitlab.com/axet/torrent@v0.0.0-20200205141541-92b4b9e7387e", "GoMod": "/usr/local/google/home/hakim/go/pkg/mod/cache/download/gitlab.com/axet/torrent/@v/v0.0.0-20200205141541-92b4b9e7387e.mod" } Also, while we are here, trim down the entries added to the generated go.mod. We need the main module, and the replaced module info. We may want to pin golang.org/x/mobile version if possible, but I don't know a reliable way to achieve that yet. Fixes golang/go#37048 Change-Id: Ibd7332338c0a3c4165a642c3e86852061f6ab13b Reviewed-on: https://go-review.googlesource.com/c/mobile/+/218057 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
gomobile failed with "replacement module directory path ... cannot have version"
Probably because gomobile does not support 'go.mod replace command'. Full log:
It also failed with "proper" version like "v0.14.0" or "libtorrent-0.14.0"
The text was updated successfully, but these errors were encountered: