Ambiguous imports on example/notify

gogio -target android gioui.org/example/notify

gogio: go build -ldflags=-w -s -X gioui.org/app/internal/log.appID=org.gioui.notify -buildmode=c-shared -tags  -o /tmp/gogio-3524532381/jni/arm64-v8a/libgio.so 

gioui.org/example/notify failed: /home/sroemen/go/pkg/mod/gioui.org/example@v0.0.0-20220331111413-bc4793259d2e/notify/main.go:20:2: ambiguous import: found package gioui.org/x/notify in multiple modules:
	gioui.org/x v0.0.0-20220318131752-bc7801f4bd03 (/home/sroemen/go/pkg/mod/gioui.org/x@v0.0.0-20220318131752-bc7801f4bd03/notify)
	gioui.org/x/notify v0.0.0-20220105205654-261c7273d121 (/home/sroemen/go/pkg/mod/gioui.org/x/notify@v0.0.0-20220105205654-261c7273d121)
Assigned to
1 year, 5 months ago
10 months ago
No labels applied.

~eliasnaur 1 year, 5 months ago

~whereswaldon 1 year, 5 months ago

I am unable to replicate this. Here's what I tried:

git clone git@git.sr.ht:~eliasnaur/gio-example
cd gio-example
go run gioui.org/cmd/gogio -target android ./notify

I also tried

go install gioui.org/cmd/gogio
gogio -target android gioui.org/example/notify

All of the above builds succeeded. ~sroemen, can you follow these steps to see whether it still fails for you?

~eliasnaur 1 year, 4 months ago

Perhaps this issue is about lazy module loading. ~sroemen, what version of Go are you using? Does Go 1.18 work for you?

~whereswaldon 11 months ago

~sroemen, any update?

~suwro 10 months ago

Hi - just got the same error on my new project.

after cloning the gio-example go mod tidy works fine,

go clean -cache -modcache -i -r rm go.mod go.sum go mod init

it will appear, it's something on gioui.org/x version I suppose!

~whereswaldon 10 months ago

It is never safe to remove go.mod. Is there some reason that you need to?

~suwro 10 months ago

if you start a new project and in it you request gioui.org/x/notify the error will appear

I removed it to emulate new project without writing something - since it is already there I just go mod init it!

whatever - the error is still there - the dilema is now why there are 2 notify versions?

~whereswaldon 10 months ago

I'm unsure of whether I can do anything about this. gioui.org/x/notify used to be its own go module, and now it isn't. The correct module is just gioui.org/x. However, the go module cache knows about the old module as well, and it doesn't seem to have any heuristic to differentiate between the two of them.

if you start a new project and in it you request gioui.org/x/notify the error will appear

I think really this is the problem. When you say "request gioui.org/x/notify", I assume you mean running:

go get gioui.org/x/notify@latest

If so, that kinda makes sense. You're asking for a module that technically does exist, but isn't latest. The correct way to get this dependency is just

go get gioui.org/x@latest

I totally get the ergonomics problem here now that I understand the operations you're performing, but I don't know if I can do anything to fix it. As far as I know, there's no way to "unpublish" the old module.

~gedw99 10 months ago

you can use the "retract" go modules command to remove the old module knowldge.


~whereswaldon REPORTED FIXED 10 months ago

The module doesn't have any tagged versions. It just kinda exists with the wrong name.

Thanks to Dominik Honnef for pointing me to this possible solution.

Following the advice in that issue, I believe I have fixed the problem:

[I] ~ $ cd /tmp
[I] /tmp $ mkdir foo
[I] /tmp $ cd foo
[I] /t/foo $ go mod init foo.com
go: creating new go.mod: module foo.com
[I] /t/foo $ go get gioui.org/x/notify@latest
go: added gioui.org v0.0.0-20220830130127-276b7eefdd65
go: added gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2
go: added gioui.org/shader v1.0.6
go: added gioui.org/x v0.0.0-20221026194128-5b5772968c5c
go: added git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0
go: added github.com/benoitkugler/textlayout v0.1.3
go: added github.com/esiqveland/notify v0.11.0
go: added github.com/gioui/uax v0.2.1-0.20220819135011-cda973fac06d
go: added github.com/go-text/typesetting v0.0.0-20220411150340-35994bc27a7b
go: added github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4
go: added github.com/godbus/dbus/v5 v5.0.6
go: added github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
go: added golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91
go: added golang.org/x/image v0.0.0-20220722155232-062f8c9fd539
go: added golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64
go: added golang.org/x/text v0.3.7
[I] /t/foo $ cat go.mod
module foo.com

go 1.19

require (
        gioui.org v0.0.0-20220830130127-276b7eefdd65 // indirect
        gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 // indirect
        gioui.org/shader v1.0.6 // indirect
        gioui.org/x v0.0.0-20221026194128-5b5772968c5c // indirect
        git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0 // indirect
        github.com/benoitkugler/textlayout v0.1.3 // indirect
        github.com/esiqveland/notify v0.11.0 // indirect
        github.com/gioui/uax v0.2.1-0.20220819135011-cda973fac06d // indirect
        github.com/go-text/typesetting v0.0.0-20220411150340-35994bc27a7b // indirect
        github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect
        github.com/godbus/dbus/v5 v5.0.6 // indirect
        github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
        golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91 // indirect
        golang.org/x/image v0.0.0-20220722155232-062f8c9fd539 // indirect
        golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 // indirect
        golang.org/x/text v0.3.7 // indirect

~whereswaldon 10 months ago

I've applied this same operation to gioui.org/x/{explorer,haptic,pref}, so I believe nobody should hit this anymore.

Register here or Log in to comment, or comment via email.