Navigation Menu

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

cmd/go: 'go mod edit' can add requirements that it can't remove #32630

Open
bcmills opened this issue Jun 14, 2019 · 2 comments
Open

cmd/go: 'go mod edit' can add requirements that it can't remove #32630

bcmills opened this issue Jun 14, 2019 · 2 comments
Labels
modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Jun 14, 2019

go mod edit -require can be used to add versions that don't match the major version of the corresponding module.

Unfortunately, the major-version validation happens early during parsing, so go mod edit -droprequire cannot subsequently drop those requirements.

example.com$ gotip mod init example.com
go: creating new go.mod: module example.com

example.com$ gotip version
go version devel +9838f4df Fri Jun 14 18:41:07 2019 +0000 linux/amd64

example.com$ gotip mod edit -require golang.org/x/text@v2.0.0

example.com$ gotip mod edit -droprequire golang.org/x/text
go: errors parsing go.mod:
/tmp/tmp.5UPKq2KvZc/example.com/go.mod:5: invalid module: golang.org/x/text should be v0 or v1, not v2 (v2.0.0)

example.com$ cat go.mod
module example.com

go 1.13

require golang.org/x/text v2.0.0

example.com$

CC @jayconrod

See also #30513, #26454.

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. modules labels Jun 14, 2019
@bcmills bcmills added this to the Go1.14 milestone Jun 14, 2019
@hyangah
Copy link
Contributor

hyangah commented Jun 17, 2019

FYI #27060 asked to validate the added requirement but was closed as working as intended.

@bcmills
Copy link
Contributor Author

bcmills commented Jun 17, 2019

Yeah, I think the fix for this should go in the other direction: we should move the major-version validation from modfile.Parse to some later step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules 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