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

Ambiguous import, cannot build example #59

Closed
ulmemxpoc opened this issue Mar 12, 2023 · 9 comments
Closed

Ambiguous import, cannot build example #59

ulmemxpoc opened this issue Mar 12, 2023 · 9 comments

Comments

@ulmemxpoc
Copy link

ulmemxpoc commented Mar 12, 2023

Ambiguous import, cannot build example.

Error

domain.com/project imports
        github.com/hajimehoshi/ebiten/v2 imports
        github.com/hajimehoshi/ebiten/v2/internal/ui imports
        golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/driver/gldriver: ambiguous import: found package golang.org/x/exp/shiny/driver/gldriver in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/home/me/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/driver/gldriver)
        golang.org/x/exp/shiny v0.0.0-20230203172020-98cc5a0785f9 (/home/me/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230203172020-98cc5a0785f9/driver/gldriver)
domain.com/project imports
        github.com/hajimehoshi/ebiten/v2 imports
        github.com/hajimehoshi/ebiten/v2/internal/ui imports
        golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/screen: ambiguous import: found package golang.org/x/exp/shiny/screen in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/home/me/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/screen)
        golang.org/x/exp/shiny v0.0.0-20230203172020-98cc5a0785f9 (/home/me/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230203172020-98cc5a0785f9/screen)

Full example

> mkdir project
> cd project
> go clean --modcache
> go mod init domain.com/project
> curl -O https://raw.githubusercontent.com/ebitenui/ebitenui/a1aa7778f9b2ab0189d75e96057a120a332d67b2/_examples/widget_demos/button/main.go
> go mod tidy
go: finding module for package golang.org/x/image/font/gofont/goregular
go: finding module for package golang.org/x/image/font
go: finding module for package github.com/ebitenui/ebitenui
go: finding module for package github.com/ebitenui/ebitenui/widget
go: finding module for package github.com/ebitenui/ebitenui/image
go: finding module for package github.com/golang/freetype/truetype
go: finding module for package github.com/hajimehoshi/ebiten/v2
go: downloading github.com/ebitenui/ebitenui v0.4.1
go: downloading github.com/hajimehoshi/ebiten/v2 v2.4.18
go: downloading golang.org/x/image v0.6.0
go: downloading github.com/hajimehoshi/ebiten v1.12.12
go: downloading github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
go: found github.com/ebitenui/ebitenui in github.com/ebitenui/ebitenui v0.4.1
go: found github.com/ebitenui/ebitenui/image in github.com/ebitenui/ebitenui v0.4.1
go: found github.com/ebitenui/ebitenui/widget in github.com/ebitenui/ebitenui v0.4.1
go: found github.com/golang/freetype/truetype in github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
go: found github.com/hajimehoshi/ebiten/v2 in github.com/hajimehoshi/ebiten/v2 v2.4.18
go: found golang.org/x/image/font in golang.org/x/image v0.6.0
go: found golang.org/x/image/font/gofont/goregular in golang.org/x/image v0.6.0
go: downloading github.com/stretchr/testify v1.8.1
go: downloading github.com/matryer/is v1.4.0
go: downloading github.com/hajimehoshi/file2byteslice v1.0.0
go: downloading github.com/hajimehoshi/bitmapfont/v2 v2.2.2
go: downloading golang.org/x/sys v0.5.0
go: downloading github.com/jezek/xgb v1.1.0
go: downloading golang.org/x/mobile v0.0.0-20221110043201-43a038452099
go: downloading github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading github.com/stretchr/objx v0.5.0
go: downloading golang.org/x/text v0.8.0
go: downloading golang.org/x/exp/shiny v0.0.0-20230203172020-98cc5a0785f9
go: downloading github.com/ebitengine/purego v0.1.1
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/capjoin: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/capjoin" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/drawer: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/drawer" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/freetype: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/freetype" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/gamma: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/gamma" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/genbasicfont: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/genbasicfont" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/raster: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/raster" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/round: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/round" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/truetype: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/truetype" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/raster: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/raster" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/truetype: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/truetype" should not have @version
domain.com/project imports
        github.com/hajimehoshi/ebiten/v2 imports
        github.com/hajimehoshi/ebiten/v2/internal/ui imports
        golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/driver/gldriver: ambiguous import: found package golang.org/x/exp/shiny/driver/gldriver in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/home/me/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/driver/gldriver)
        golang.org/x/exp/shiny v0.0.0-20230203172020-98cc5a0785f9 (/home/me/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230203172020-98cc5a0785f9/driver/gldriver)
domain.com/project imports
        github.com/hajimehoshi/ebiten/v2 imports
        github.com/hajimehoshi/ebiten/v2/internal/ui imports
        golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/screen: ambiguous import: found package golang.org/x/exp/shiny/screen in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/home/me/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/screen)
        golang.org/x/exp/shiny v0.0.0-20230203172020-98cc5a0785f9 (/home/me/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230203172020-98cc5a0785f9/screen)
> go build
main.go:7:2: no required module provides package github.com/ebitenui/ebitenui; to add it:
        go get github.com/ebitenui/ebitenui
main.go:8:2: no required module provides package github.com/ebitenui/ebitenui/image; to add it:
        go get github.com/ebitenui/ebitenui/image
main.go:9:2: no required module provides package github.com/ebitenui/ebitenui/widget; to add it:
        go get github.com/ebitenui/ebitenui/widget
main.go:10:2: no required module provides package github.com/golang/freetype/truetype; to add it:
        go get github.com/golang/freetype/truetype
main.go:11:2: no required module provides package github.com/hajimehoshi/ebiten/v2; to add it:
        go get github.com/hajimehoshi/ebiten/v2
main.go:12:2: no required module provides package golang.org/x/image/font; to add it:
        go get golang.org/x/image/font
main.go:13:2: no required module provides package golang.org/x/image/font/gofont/goregular; to add it:
        go get golang.org/x/image/font/gofont/goregular
@mcarpenter622
Copy link
Collaborator

The examples do not have their own go.mod file. You can run them from the root of the project like:
PS C:\BirdMtnDev\Resources\ebitenui> go run ./_examples/widget_demos/button
PS C:\BirdMtnDev\Resources\ebitenui> go build ./_examples/widget_demos/button
PS C:\BirdMtnDev\Resources\ebitenui> ./button.exe
PS C:\BirdMtnDev\Resources\ebitenui>

Or if you use VS code there are run commands setup for each.
If you want to copy the code, you will need to build your go.mod file as needed.

@mcarpenter622
Copy link
Collaborator

This section of the error message you see is the key. You would need to run each of those "go get" commands.

main.go:7:2: no required module provides package github.com/ebitenui/ebitenui; to add it:
go get github.com/ebitenui/ebitenui
main.go:8:2: no required module provides package github.com/ebitenui/ebitenui/image; to add it:
go get github.com/ebitenui/ebitenui/image
main.go:9:2: no required module provides package github.com/ebitenui/ebitenui/widget; to add it:
go get github.com/ebitenui/ebitenui/widget
main.go:10:2: no required module provides package github.com/golang/freetype/truetype; to add it:
go get github.com/golang/freetype/truetype
main.go:11:2: no required module provides package github.com/hajimehoshi/ebiten/v2; to add it:
go get github.com/hajimehoshi/ebiten/v2
main.go:12:2: no required module provides package golang.org/x/image/font; to add it:
go get golang.org/x/image/font
main.go:13:2: no required module provides package golang.org/x/image/font/gofont/goregular; to add it:
go get golang.org/x/image/font/gofont/goregular

@ulmemxpoc
Copy link
Author

ulmemxpoc commented Mar 12, 2023

go get github.com/ebitenui/ebitenui
go get github.com/ebitenui/ebitenui/image
go get github.com/ebitenui/ebitenui/widget
go get github.com/golang/freetype/truetype
go get github.com/hajimehoshi/ebiten/v2
go get golang.org/x/image/font
go get golang.org/x/image/font/gofont/goregular

# go/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.4.18/internal/gamepad/api_linux.go:23:2: missing go.sum entry for module providing package golang.org/x/sys/unix (imported by github.com/hajimehoshi/ebiten/v2/internal/gamepad); to add:
go get github.com/hajimehoshi/ebiten/v2/internal/gamepad@v2.4.18

makes go build work, but go mod tidy after the above go getting does not:

> go mod tidy
domain.com/project/go/pkg/mod/github.com/davecgh/go-spew@v1.1.1/spew: import path "domain.com/project/go/pkg/mod/github.com/davecgh/go-spew@v1.1.1/spew" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/capjoin: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/capjoin" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/drawer: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/drawer" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/freetype: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/freetype" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/gamma: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/gamma" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/genbasicfont: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/genbasicfont" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/raster: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/raster" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/round: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/round" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/truetype: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/example/truetype" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/raster: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/raster" should not have @version
domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/truetype: import path "domain.com/project/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/truetype" should not have @version
domain.com/project/go/pkg/mod/github.com/pmezard/go-difflib@v1.0.0/difflib: import path "domain.com/project/go/pkg/mod/github.com/pmezard/go-difflib@v1.0.0/difflib" should not have @version

Is this normal?

@mcarpenter622
Copy link
Collaborator

That is not normal. I don't know why you would be seeing an issue like that

@ulmemxpoc
Copy link
Author

Turns out it was user error. Project cannot be in home dir. Moving anywhere else fixes it.

@mcarpenter622
Copy link
Collaborator

Thank you for the update!

@ulmemxpoc
Copy link
Author

ulmemxpoc commented Mar 14, 2023

Okay, after digging some more, and sometimes reproducing issue outside of home dir, here is more details.

Min example

main.go

package main

import (
	_ "github.com/ebitenui/ebitenui"
	_ "github.com/hajimehoshi/ebiten/v2"
)

func main() {}
> mkdir project
> cd project
> # add main.go contents
> go clean -modcache
> rm -f go.md go.sum
> go mod init domain.com/project
> go mod tidy
go: finding module for package github.com/hajimehoshi/ebiten/v2
go: finding module for package github.com/ebitenui/ebitenui
go: downloading github.com/ebitenui/ebitenui v0.4.2
go: downloading github.com/hajimehoshi/ebiten v1.12.12
go: downloading github.com/hajimehoshi/ebiten/v2 v2.4.18
go: found github.com/ebitenui/ebitenui in github.com/ebitenui/ebitenui v0.4.2
go: found github.com/hajimehoshi/ebiten/v2 in github.com/hajimehoshi/ebiten/v2 v2.4.18
go: downloading github.com/hajimehoshi/file2byteslice v1.0.0
go: downloading github.com/jezek/xgb v1.1.0
go: downloading golang.org/x/mobile v0.0.0-20221110043201-43a038452099
go: downloading golang.org/x/sys v0.4.0
go: downloading github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b
go: downloading github.com/matryer/is v1.4.0
go: downloading github.com/stretchr/testify v1.8.1
go: downloading golang.org/x/image v0.3.0
go: downloading github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
go: downloading golang.org/x/exp/shiny v0.0.0-20230203172020-98cc5a0785f9
go: downloading github.com/ebitengine/purego v0.1.1
go: downloading github.com/hajimehoshi/bitmapfont/v2 v2.2.2
go: downloading golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading github.com/stretchr/objx v0.5.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading golang.org/x/text v0.6.0
domain.com/project imports
        github.com/hajimehoshi/ebiten/v2 imports
        github.com/hajimehoshi/ebiten/v2/internal/ui imports
        golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/driver/gldriver: ambiguous import: found package golang.org/x/exp/shiny/driver/gldriver in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/home/me/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/driver/gldriver)
        golang.org/x/exp/shiny v0.0.0-20230203172020-98cc5a0785f9 (/home/me/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230203172020-98cc5a0785f9/driver/gldriver)
domain.com/project imports
        github.com/hajimehoshi/ebiten/v2 imports
        github.com/hajimehoshi/ebiten/v2/internal/ui imports
        golang.org/x/mobile/app imports
        golang.org/x/exp/shiny/screen: ambiguous import: found package golang.org/x/exp/shiny/screen in multiple modules:
        golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 (/home/me/go/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/shiny/screen)
        golang.org/x/exp/shiny v0.0.0-20230203172020-98cc5a0785f9 (/home/me/go/pkg/mod/golang.org/x/exp/shiny@v0.0.0-20230203172020-98cc5a0785f9/screen)
> go build
main.go:4:2: no required module provides package github.com/ebitenui/ebitenui; to add it:
        go get github.com/ebitenui/ebitenui
main.go:5:2: no required module provides package github.com/hajimehoshi/ebiten/v2; to add it:
        go get github.com/hajimehoshi/ebiten/v2

To test, use this one-liner: go clean -modcache; rm -f go.mod go.sum; go mod init domain.com/project; go mod tidy; go build

Workaround

> # Retrieves ebiten/v2 (v2.4.16) instead of ebiten/v2 (v2.4.18)
> go get github.com/ebitenui/ebitenui
> # OR get ebiten/v2 (v2.4.18) directly, and add ebitenui from go mod tidy
> go get github.com/hajimehoshi/ebiten/v2; go mod tidy

go mod tidy works after using one of the two above lines.

Cause (?)

ebitenui depends on ebiten/v2 (v2.4.16), but ebiten/v2 (v2.4.16) conflicts with ebiten/v2 (v2.4.18).

Proposed fix

Upgrade ebitenui/go.mod from ebiten/v2 v2.4.16 to ebiten/v2 v2.4.18.

@ulmemxpoc ulmemxpoc reopened this Mar 14, 2023
@mcarpenter622
Copy link
Collaborator

So I just released a new version that is based on ebitengine's newest release 2.5.0. I believe that should resolve your issue. Let me know. I'm planning on closing this ticket in a few days unless there are any concerns that come up.

@mcarpenter622
Copy link
Collaborator

No comments in the past month and a new version was released again v0.5.0. I am closing this issue. Please reopen if you still have concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants