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

v3: import ambiguity error #889

Closed
1 task done
ucirello opened this issue Jan 7, 2025 · 3 comments
Closed
1 task done

v3: import ambiguity error #889

ucirello opened this issue Jan 7, 2025 · 3 comments
Labels

Comments

@ucirello
Copy link

ucirello commented Jan 7, 2025

Description

In a clean slate module with an valid go.mod, go run github.com/vektra/mockery/v3 errors.

go.mod:

module github.com/axiomhq/test

go 1.24rc1

require (
        github.com/brunoga/deep v1.2.4 // indirect
        github.com/chigopher/pathlib v0.19.1 // indirect
        github.com/fatih/structs v1.1.0 // indirect
        github.com/fsnotify/fsnotify v1.8.0 // indirect
        github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
        github.com/huandu/xstrings v1.5.0 // indirect
        github.com/inconshreveable/mousetrap v1.1.0 // indirect
        github.com/knadh/koanf/maps v0.1.1 // indirect
        github.com/knadh/koanf/parsers/yaml v0.1.0 // indirect
        github.com/knadh/koanf/providers/env v1.0.0 // indirect
        github.com/knadh/koanf/providers/file v1.1.2 // indirect
        github.com/knadh/koanf/providers/posflag v0.1.0 // indirect
        github.com/knadh/koanf/providers/structs v0.1.0 // indirect
        github.com/knadh/koanf/v2 v2.1.2 // indirect
        github.com/mattn/go-colorable v0.1.13 // indirect
        github.com/mattn/go-isatty v0.0.20 // indirect
        github.com/mitchellh/copystructure v1.2.0 // indirect
        github.com/mitchellh/reflectwalk v1.0.2 // indirect
        github.com/rs/zerolog v1.33.0 // indirect
        github.com/spf13/afero v1.11.0 // indirect
        github.com/spf13/cobra v1.8.1 // indirect
        github.com/spf13/pflag v1.0.5 // indirect
        github.com/vektra/mockery/v3 v3.0.0-alpha.19 // indirect
        golang.org/x/mod v0.22.0 // indirect
        golang.org/x/sync v0.10.0 // indirect
        golang.org/x/sys v0.29.0 // indirect
        golang.org/x/term v0.27.0 // indirect
        golang.org/x/text v0.21.0 // indirect
        golang.org/x/tools v0.28.0 // indirect
        gopkg.in/yaml.v3 v3.0.1 // indirect
)

Mockery Version

v3.0.0-alpha.19

Go Version

go 1.24rc1

Installation Method

  • go install

Steps to Reproduce

  1. mkdir project
  2. go mod init
  3. go get github.com/vektra/mockery/[email protected]
  4. go clean -cache -modcache
  5. go run github.com/vektra/mockery/v3

Expected Behavior

It should work.

Actual Behavior

It errors with:

../../../../pkg/mod/github.com/vektra/mockery/[email protected]/internal/cmd/showconfig.go:7:2: ambiguous import: found package github.com/knadh/koanf/parsers/yaml in multiple modules:
        github.com/knadh/koanf v1.5.0 (/Users/user/go/pkg/mod/github.com/knadh/[email protected]/parsers/yaml)
        github.com/knadh/koanf/parsers/yaml v0.1.0 (/Users/user/go/pkg/mod/github.com/knadh/koanf/parsers/[email protected])
../../../../pkg/mod/github.com/vektra/mockery/[email protected]/internal/cmd/showconfig.go:8:2: ambiguous import: found package github.com/knadh/koanf/providers/structs in multiple modules:
        github.com/knadh/koanf v1.5.0 (/Users/user/go/pkg/mod/github.com/knadh/[email protected]/providers/structs)
        github.com/knadh/koanf/providers/structs v0.1.0 (/Users/user/go/pkg/mod/github.com/knadh/koanf/providers/[email protected])
../../../../pkg/mod/github.com/knadh/koanf/[email protected]/koanf.go:11:2: ambiguous import: found package github.com/knadh/koanf/maps in multiple modules:
        github.com/knadh/koanf v1.5.0 (/Users/user/go/pkg/mod/github.com/knadh/[email protected]/maps)
        github.com/knadh/koanf/maps v0.1.1 (/Users/user/go/pkg/mod/github.com/knadh/koanf/[email protected])
../../../../pkg/mod/github.com/vektra/mockery/[email protected]/internal/config.go:20:2: ambiguous import: found package github.com/knadh/koanf/providers/env in multiple modules:
        github.com/knadh/koanf v1.5.0 (/Users/user/go/pkg/mod/github.com/knadh/[email protected]/providers/env)
        github.com/knadh/koanf/providers/env v1.0.0 (/Users/user/go/pkg/mod/github.com/knadh/koanf/providers/[email protected])
../../../../pkg/mod/github.com/vektra/mockery/[email protected]/internal/config.go:21:2: ambiguous import: found package github.com/knadh/koanf/providers/file in multiple modules:
        github.com/knadh/koanf v1.5.0 (/Users/user/go/pkg/mod/github.com/knadh/[email protected]/providers/file)
        github.com/knadh/koanf/providers/file v1.1.2 (/Users/user/go/pkg/mod/github.com/knadh/koanf/providers/[email protected])
../../../../pkg/mod/github.com/vektra/mockery/[email protected]/internal/config.go:22:2: ambiguous import: found package github.com/knadh/koanf/providers/posflag in multiple modules:
        github.com/knadh/koanf v1.5.0 (/Users/user/go/pkg/mod/github.com/knadh/[email protected]/providers/posflag)
        github.com/knadh/koanf/providers/posflag v0.1.0 (/Users/user/go/pkg/mod/github.com/knadh/koanf/providers/[email protected])
@LandonTClipp
Copy link
Collaborator

LandonTClipp commented Jan 14, 2025

I'm not able to reproduce this. I followed the steps listed.

 $ go version
go version go1.23.3 darwin/arm64
 $ cat go.mod 
module test

go 1.23.3

require (
        github.com/brunoga/deep v1.2.4 // indirect
        github.com/chigopher/pathlib v0.19.1 // indirect
        github.com/fatih/structs v1.1.0 // indirect
        github.com/fsnotify/fsnotify v1.8.0 // indirect
        github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
        github.com/huandu/xstrings v1.5.0 // indirect
        github.com/inconshreveable/mousetrap v1.1.0 // indirect
        github.com/knadh/koanf/maps v0.1.1 // indirect
        github.com/knadh/koanf/parsers/yaml v0.1.0 // indirect
        github.com/knadh/koanf/providers/env v1.0.0 // indirect
        github.com/knadh/koanf/providers/file v1.1.2 // indirect
        github.com/knadh/koanf/providers/posflag v0.1.0 // indirect
        github.com/knadh/koanf/providers/structs v0.1.0 // indirect
        github.com/knadh/koanf/v2 v2.1.2 // indirect
        github.com/mattn/go-colorable v0.1.13 // indirect
        github.com/mattn/go-isatty v0.0.20 // indirect
        github.com/mitchellh/copystructure v1.2.0 // indirect
        github.com/mitchellh/reflectwalk v1.0.2 // indirect
        github.com/rs/zerolog v1.33.0 // indirect
        github.com/spf13/afero v1.11.0 // indirect
        github.com/spf13/cobra v1.8.1 // indirect
        github.com/spf13/pflag v1.0.5 // indirect
        github.com/vektra/mockery/v3 v3.0.0-alpha.19 // indirect
        golang.org/x/mod v0.22.0 // indirect
        golang.org/x/sync v0.10.0 // indirect
        golang.org/x/sys v0.29.0 // indirect
        golang.org/x/term v0.27.0 // indirect
        golang.org/x/text v0.21.0 // indirect
        golang.org/x/tools v0.28.0 // indirect
        gopkg.in/yaml.v3 v3.0.1 // indirect
)
 $ go get github.com/vektra/mockery/[email protected]
go: downloading github.com/vektra/mockery/v3 v3.0.0-alpha.19
go: added github.com/brunoga/deep v1.2.4
go: added github.com/chigopher/pathlib v0.19.1                                                                             
go: added github.com/fatih/structs v1.1.0
go: added github.com/fsnotify/fsnotify v1.8.0
go: added github.com/go-viper/mapstructure/v2 v2.2.1
go: added github.com/huandu/xstrings v1.5.0
go: added github.com/inconshreveable/mousetrap v1.1.0
go: added github.com/knadh/koanf/maps v0.1.1                                                                               
go: added github.com/knadh/koanf/parsers/yaml v0.1.0
go: added github.com/knadh/koanf/providers/env v1.0.0
go: added github.com/knadh/koanf/providers/file v1.1.2
go: added github.com/knadh/koanf/providers/posflag v0.1.0                                                                                                                                                                                             
go: added github.com/knadh/koanf/providers/structs v0.1.0                                                                  
go: added github.com/knadh/koanf/v2 v2.1.2                                                                                                                                                                                                            
go: added github.com/mattn/go-colorable v0.1.13
go: added github.com/mattn/go-isatty v0.0.20                                                                               
go: added github.com/mitchellh/copystructure v1.2.0
go: added github.com/mitchellh/reflectwalk v1.0.2
go: added github.com/rs/zerolog v1.33.0
go: added github.com/spf13/afero v1.11.0
go: added github.com/spf13/cobra v1.8.1
go: added github.com/spf13/pflag v1.0.5
go: added github.com/vektra/mockery/v3 v3.0.0-alpha.19
go: added golang.org/x/mod v0.22.0
go: added golang.org/x/sync v0.10.0
go: added golang.org/x/sys v0.29.0
go: added golang.org/x/term v0.27.0               
go: added golang.org/x/text v0.21.0                     
go: added golang.org/x/tools v0.28.0               
go: added gopkg.in/yaml.v3 v3.0.1     
[ 10:12PM ]  [ landon@A02257:/tmp/test ]                                                                                   
 $ go clean -cache -modcache                         
[ 10:12PM ]  [ landon@A02257:/tmp/test ]                                                                                   
 $ go run github.com/vektra/mockery/v3                
go: downloading github.com/vektra/mockery/v3 v3.0.0-alpha.19                                                               
go: downloading golang.org/x/tools v0.28.0                                                                                 
go: downloading github.com/knadh/koanf/parsers/yaml v0.1.0                                                                 
go: downloading github.com/knadh/koanf/v2 v2.1.2                                                                           
go: downloading github.com/rs/zerolog v1.33.0                                                                              
go: downloading github.com/spf13/cobra v1.8.1       
go: downloading github.com/chigopher/pathlib v0.19.1     
go: downloading github.com/knadh/koanf/providers/structs v0.1.0
go: downloading github.com/spf13/pflag v1.0.5                                                                              
go: downloading github.com/brunoga/deep v1.2.4             
go: downloading github.com/knadh/koanf/providers/env v1.0.0
go: downloading github.com/knadh/koanf/providers/file v1.1.2
go: downloading github.com/knadh/koanf/providers/posflag v0.1.0
go: downloading golang.org/x/term v0.27.0        
go: downloading github.com/go-viper/mapstructure/v2 v2.2.1                                                                 
go: downloading github.com/knadh/koanf/maps v0.1.1
go: downloading github.com/mitchellh/copystructure v1.2.0
go: downloading github.com/spf13/afero v1.11.0
go: downloading github.com/fatih/structs v1.1.0
go: downloading github.com/huandu/xstrings v1.5.0
go: downloading gopkg.in/yaml.v3 v3.0.1       
go: downloading github.com/mattn/go-colorable v0.1.13
go: downloading github.com/fsnotify/fsnotify v1.8.0
go: downloading golang.org/x/sys v0.29.0
go: downloading github.com/mitchellh/reflectwalk v1.0.2
go: downloading golang.org/x/text v0.21.0
go: downloading github.com/mattn/go-isatty v0.0.20
go: downloading golang.org/x/sync v0.10.0
go: downloading golang.org/x/mod v0.22.0
failed to get config: discovering mockery config: mockery config file not found
goroutine 1 [running]:

@ucirello
Copy link
Author

Weird - I can't reproduce my own steps now. I apologize for the noise.

@ucirello
Copy link
Author

After some out of band investigation, I managed to isolate to a go workspace issue, in which the two repositories composing the workspace did not have the same version. GOWORK=off go run ... made it work correctly.

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

No branches or pull requests

2 participants