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/run: error hint for "no required module provides package" is not helpful #60944

Open
ConradIrwin opened this issue Jun 22, 2023 · 1 comment
Labels
GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ConradIrwin
Copy link
Contributor

In a directory that contains a go.mod, use go run to run a package that is not in the dependency graph with no version specified. Currently we tell you to go get tool. This probably isn't what you want (it will temporarily add the tool to your module, but it will be removed on the next go mod tidy). We should consider removing this hint.

$ go run golang.org/x/tools/cmd/stringer
no required module provides package golang.org/x/tools/cmd/stringer; to add it:
	go get golang.org/x/tools/cmd/stringer

I created this issue to track the work mentioned on this comment from @rsc on #48429 (comment)

@ConradIrwin, I think that error message change is not correct. If people are using "go run" then we shouldn't tell them to do something that is meant to be used with "go tool" but accidentally also makes "go run" work. Honestly I think the "to add it" note should probably be removed entirely. There are two possible ways to fix that error. The other is to add @Version to the command line. Often that's what you want instead. We should stop presuming one solution.

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. GoCommand cmd/go labels Jun 22, 2023
@bcmills bcmills added this to the Go1.22 milestone Jun 22, 2023
@bcmills bcmills modified the milestones: Go1.22, Backlog Jun 22, 2023
@huhouhua
Copy link

check whether the golang.org/x/tools/cmd/stringer path is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go help wanted 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