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
Labels
Milestone

Comments

@bcmills
Copy link
Member

@bcmills 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 this to the Go1.14 milestone Jun 14, 2019
@hyangah

This comment has been minimized.

Copy link
Contributor

@hyangah hyangah commented Jun 17, 2019

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

@bcmills

This comment has been minimized.

Copy link
Member Author

@bcmills 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.

@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.