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: ambiguous import error when running go mod tidy #62415

Closed
hajimehoshi opened this issue Sep 1, 2023 · 7 comments
Closed

x/mobile: ambiguous import error when running go mod tidy #62415

hajimehoshi opened this issue Sep 1, 2023 · 7 comments
Labels
mobile Android, iOS, and x/mobile NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hajimehoshi
Copy link
Member

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

$ go version
go version go1.20.4 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/hajimehoshi/Library/Caches/go-build"
GOENV="/Users/hajimehoshi/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/hajimehoshi/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/hajimehoshi/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/hajimehoshi/go-x-mobile/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/60/khbk2xqn1c5bml1byjn89dwc0000gn/T/go-build532030637=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Run go mod tidy in gomobile. The gomobile version is 52620a4a7557849149770d52fd7b580cb3cbd1ae

What did you expect to see?

No errors

What did you see instead?

golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/driver/gldriver loaded from golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63,
        but go 1.16 would fail to locate it:
        ambiguous import: found package golang.org/x/exp/shiny/driver/gldriver in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/driver/gldriver)
        golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63/driver/gldriver)
golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/screen loaded from golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63,
        but go 1.16 would fail to locate it:
        ambiguous import: found package golang.org/x/exp/shiny/screen in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/screen)
        golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63/screen)
golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/driver/gldriver imports
        golang.org/x/exp/shiny/driver/internal/drawer loaded from golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63,
        but go 1.16 would fail to locate it:
        ambiguous import: found package golang.org/x/exp/shiny/driver/internal/drawer in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/driver/internal/drawer)
        golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63/driver/internal/drawer)
golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/driver/gldriver imports
        golang.org/x/exp/shiny/driver/internal/errscreen loaded from golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63,
        but go 1.16 would fail to locate it:
        ambiguous import: found package golang.org/x/exp/shiny/driver/internal/errscreen in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/driver/internal/errscreen)
        golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63/driver/internal/errscreen)
golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/driver/gldriver imports
        golang.org/x/exp/shiny/driver/internal/event loaded from golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63,
        but go 1.16 would fail to locate it:
        ambiguous import: found package golang.org/x/exp/shiny/driver/internal/event in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/driver/internal/event)
        golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63/driver/internal/event)
golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/driver/gldriver imports
        golang.org/x/exp/shiny/driver/internal/lifecycler loaded from golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63,
        but go 1.16 would fail to locate it:
        ambiguous import: found package golang.org/x/exp/shiny/driver/internal/lifecycler in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/driver/internal/lifecycler)
        golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63/driver/internal/lifecycler)
golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/driver/gldriver imports
        golang.org/x/exp/shiny/driver/internal/win32 loaded from golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63,
        but go 1.16 would fail to locate it:
        ambiguous import: found package golang.org/x/exp/shiny/driver/internal/win32 in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/driver/internal/win32)
        golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63/driver/internal/win32)
golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/driver/gldriver imports
        golang.org/x/exp/shiny/driver/internal/x11key loaded from golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63,
        but go 1.16 would fail to locate it:
        ambiguous import: found package golang.org/x/exp/shiny/driver/internal/x11key in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/driver/internal/x11key)
        golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 (/Users/hajimehoshi/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230817173708-d852ddb80c63/driver/internal/x11key)

To proceed despite packages unresolved in go 1.16:
        go mod tidy -e
If reproducibility with go 1.16 is not needed:
        go mod tidy -compat=1.17
For other options, see:
        https://golang.org/doc/modules/pruning

Of course go mod tidy -compat=1.17 worked, but is there a good solution to fix this?

@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Sep 1, 2023
@gopherbot gopherbot added this to the Unreleased milestone Sep 1, 2023
@hajimehoshi
Copy link
Member Author

Do you have any insights? @dmitshur

@dmitshur
Copy link
Contributor

dmitshur commented Sep 1, 2023

The go directive in x/mobile is set to 1.17. Given by now only Go 1.21 and 1.20 releases are supported per policy, let's fix this by bumping to a newer Go language for the module: one of 1.18, 1.19 or 1.20.

@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 1, 2023
@hajimehoshi
Copy link
Member Author

Ah OK, thanks. I'll send a CL soon.

@gopherbot
Copy link

Change https://go.dev/cl/525095 mentions this issue: all: update Go version to 1.18

hajimehoshi added a commit to hajimehoshi/ebiten that referenced this issue Sep 1, 2023
This reverts these commit:

* 7f0a86f.
* b615aaf.

Reason: Test failures. See golang/go#62415
@hajimehoshi
Copy link
Member Author

By the way, from the error message

To proceed despite packages unresolved in go 1.16:
        go mod tidy -e
If reproducibility with go 1.16 is not needed:
        go mod tidy -compat=1.17
For other options, see:
        https://golang.org/doc/modules/pruning

I couldn't reach the current solution. The URL seems outdated. Would it be possible to get a better error message for this?

@hajimehoshi
Copy link
Member Author

hajimehoshi commented Sep 1, 2023

Another mystery thing is

The -compat flag preserves any additional checksums needed for the
'go' command from the indicated major Go release to successfully load
the module graph, and causes tidy to error out if that version of the
'go' command would load any imported package from a different module
version. By default, tidy acts as if the -compat flag were set to the
version prior to the one indicated by the 'go' directive in the go.mod
file.

so go mod tidy should behave as go mod tidy -compat=1.17 with the current gomobile, but the behaviors with and without the flag were different.

EDIT:

prior to the one

Ah, so if go.mod says go1.17, does this mean go mod tidy behaves as go mod tidy -compat=1.16? Then that makes sense...

@dmitshur
Copy link
Contributor

dmitshur commented Sep 1, 2023

Sorry it's a bit confusing. There's a good description at https://go.dev/ref/mod#graph-pruning. Given this is only relevant to older Go versions that aren't supported by now, I don't think there's anything to other than to move forward. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants