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

SetRequire called with conflicting versions #24

Closed
HenrikPoulsen opened this issue Oct 31, 2023 · 6 comments
Closed

SetRequire called with conflicting versions #24

HenrikPoulsen opened this issue Oct 31, 2023 · 6 comments

Comments

@HenrikPoulsen
Copy link

I am using Renovate which uses mod.
I am getting the following in both Renovate as well as locally:

mod upgrade --mod-name=gopkg.in/yaml.v2 -t=3
panic: SetRequire called with conflicting versions for path gopkg.in/yaml.v3 (latest and v3.0.1)

I am not really finding anything online indicating that others have had this issue before.
Any idea what might cause this?

@HenrikPoulsen
Copy link
Author

If I downgrade the project and go to version 1.20.10 then it works.
I was running 1.21.3, so I assume something has changed in newer go versions that breaks this.

@HenrikPoulsen
Copy link
Author

Haven't been able to make a simple reproduction.
But the issue is that in modFile.Require at https://github.com/marwan-at-work/mod/blob/master/major/major.go#L65-L72 for some reason ends up having both gopkg.in/yaml.v2 and gopkg.in/yaml.v3 in there already. So it replaces gopkg.in/yaml.v2 with gopkg.in/yaml.v3 and now has two v3 entries in there, which SetRequire does not like.
Tried modifying the code locally to remove the existing v3 to remove that conflict and then it works just fine.

@marwan-at-work
Copy link
Owner

Haven't been able to make a simple reproduction.

If you are able to, please feel free to post it. I'll try to reproduce it myself if/when I get some free time.

Thanks for reporting!

@HenrikPoulsen
Copy link
Author

I managed to make a minimal repro it seems. Try https://github.com/HenrikPoulsen/mod-setrequire-repro
Interestingly I wasn't able to reproduce that it was only broken on 1.21. Tried the latest version of 1.18, 1.19 and 1.20 and they all seemed to give the same result oddly enough.

To reproduce I used the following docker command docker run -it --rm -v .:/repo golang:1.21.3-alpine3.18
and in the container I ran cd /repo && go install github.com/marwan-at-work/mod/cmd/mod@latest && mod upgrade --mod-name=gopkg.in/yaml.v2 -t=3
which yields:

panic: SetRequire called with conflicting versions for path gopkg.in/yaml.v3 (latest and v3.0.1)

goroutine 1 [running]:
golang.org/x/mod/modfile.(*File).SetRequire(0xc000192a00, {0xc000194700, 0x1f, 0xc0000cb990?})
        /go/pkg/mod/golang.org/x/mod@v0.13.0/modfile/rule.go:1088 +0x4c5
github.com/marwan-at-work/mod/major.Run({0xa827a8, 0x1}, {0x9b10df, 0x7}, {0x7ffe4ea8befe, 0x10}, 0xdd4a60?)
        /go/pkg/mod/github.com/marwan-at-work/mod@v0.7.0/major/major.go:72 +0x7ac
main.upgrade(0x8ff1a0?)
        /go/pkg/mod/github.com/marwan-at-work/mod@v0.7.0/cmd/mod/main.go:75 +0x6f
main.main.withExit.func1(0xc0000fa2c0?)
        /go/pkg/mod/github.com/marwan-at-work/mod@v0.7.0/cmd/mod/main.go:88 +0x17
github.com/urfave/cli/v2.(*Command).Run(0xc0000fa2c0, 0xc0000b2c40, {0xc000097710, 0x3, 0x3})
        /go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/command.go:274 +0x998
github.com/urfave/cli/v2.(*Command).Run(0xc0000fa840, 0xc0000b2b80, {0xc0000b2040, 0x4, 0x4})
        /go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/command.go:267 +0xbe5
github.com/urfave/cli/v2.(*App).RunContext(0xc000204000, {0xa8bda8?, 0xe030e0}, {0xc0000b2040, 0x4, 0x4})
        /go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/app.go:332 +0x5b7
github.com/urfave/cli/v2.(*App).Run(...)
        /go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/app.go:309
main.main()
        /go/pkg/mod/github.com/marwan-at-work/mod@v0.7.0/cmd/mod/main.go:71 +0x68b

Hope this helps and you are able to reproduce it without any issues.

@oschwald
Copy link

oschwald commented Nov 6, 2023

I am also experiencing this same issue:

Command failed: mod upgrade --mod-name=github.com/deepmap/oapi-codegen -t=2
panic: SetRequire called with conflicting versions for path github.com/deepmap/oapi-codegen/v2 (latest and v2.0.0)

goroutine 1 [running]:
golang.org/x/mod/modfile.(*File).SetRequire(0xc000164b80, {0xc000228000, 0x149, 0xc0002045d0?})
...

It was working until recently, which makes me think it is new to 0.6.0 or 0.7.0.

We are also using Go 1.21, but we upgraded a couple of months ago and this is the first time I recall seeing this.

@marwan-at-work
Copy link
Owner

Thank you @HenrikPoulsen for the repro. The reason this was failing is because your go.mod file already contained gopkg.in/yaml.v3

I imagine this is also why @oschwald saw a similar error, assuming their go.mod file already contained the .../oapi-codegen/v2 module.

I pushed a fix here: 2a21052

And created v0.7.1 release, if this bug continues to persist please re-open the issue.

Thanks!

PS. It might be worth adding tests for this issue.

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

No branches or pull requests

3 participants