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: confusing error for non-existent go source files #48559

Open
rsc opened this issue Sep 22, 2021 · 7 comments
Open

cmd/go: confusing error for non-existent go source files #48559

rsc opened this issue Sep 22, 2021 · 7 comments
Assignees
Labels
NeedsInvestigation
Milestone

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Sep 22, 2021

% go build notexist.go
cannot find package "." in:
	/Users/rsc/go/src/notexist.go
% 

For what it's worth, I'm not in /Users/rsc/go/src.
That's just the error looking for a std package named notexist.go.
It should show me an error more like 'no such file notexist.go'.

/cc @bcmills @jayconrod @matloob

@rsc rsc added this to the Go1.18 milestone Sep 22, 2021
@robpike robpike changed the title cmd/go: confusing error for non-existant go source files cmd/go: confusing error for non-existent go source files Sep 22, 2021
@mknyszek mknyszek added the NeedsInvestigation label Oct 4, 2021
@heschi
Copy link
Contributor

@heschi heschi commented Oct 6, 2021

Ping from the release team: any updates on this release blocker?

@heschi heschi closed this as completed Oct 6, 2021
@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Oct 6, 2021

Briefly looked into this, but wasn't able to reproduce it. Outside a module in 1.17.1, I see this:

$ go build notexist.go
no required module provides package notexist.go: go.mod file not found in current directory or any parent directory; see 'go help modules'

Inside a module:

$ go build notexist.go
no required module provides package notexist.go; to add it:
        go get notexist.go

What version of Go was this? What does go env show?

@jayconrod jayconrod reopened this Oct 6, 2021
@jayconrod jayconrod added the WaitingForInfo label Oct 6, 2021
@bcmills bcmills self-assigned this Oct 6, 2021
@dmitshur dmitshur removed the WaitingForInfo label Nov 3, 2021
@bcmills bcmills added the okay-after-beta1 label Nov 19, 2021
@bcmills bcmills removed the okay-after-beta1 label Jan 6, 2022
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jan 29, 2022

@bcmills This is in the 1.18 milestone; time to move to 1.19? Thanks.

(The current error isn't great since it treats nonexist.go as the name of a package. That is technically correct but maybe if it doesn't exist we can treat a trailing ".go" as a special case and give a different error message.)

@bcmills bcmills reopened this Jan 29, 2022
@bcmills bcmills removed this from the Go1.18 milestone Jan 29, 2022
@bcmills bcmills added this to the Go1.19 milestone Jan 29, 2022
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jan 29, 2022

Whoops, sorry, didn't mean to close this.

@bcmills
Copy link
Member

@bcmills bcmills commented Feb 16, 2022

This was improved somewhat by the fix for #48907, but it's still not ideal.

@bcmills
Copy link
Member

@bcmills bcmills commented Feb 17, 2022

This also turns out to be another in the cluster of go list -e error-reporting bugs. There are a number of base.Fatalf calls in load.GoFilesPackage that could just as easily be returned as errors.

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 17, 2022

Change https://go.dev/cl/386496 mentions this issue: cmd/go: improve error handling for nonexistent files

@bcmills bcmills removed this from the Go1.19 milestone Jun 30, 2022
@bcmills bcmills added this to the Go1.20 milestone Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation
Projects
Status: No status
Development

No branches or pull requests

9 participants