Skip to content

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

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

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
Labels
BadErrorMessage Issues related compiler error messages that should be better. GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rsc
Copy link
Contributor

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 Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 4, 2021
@heschi
Copy link
Contributor

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

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 Issue is not actionable because of missing required information, which needs to be provided. label Oct 6, 2021
@bcmills bcmills self-assigned this Oct 6, 2021
@dmitshur dmitshur removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 3, 2021
@bcmills bcmills added the okay-after-beta1 Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1 label Nov 19, 2021
@bcmills bcmills removed the okay-after-beta1 Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1 label Jan 6, 2022
@ianlancetaylor
Copy link
Member

@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 modified the milestones: Go1.18, Go1.19 Jan 29, 2022
@ianlancetaylor
Copy link
Member

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

@bcmills
Copy link
Contributor

bcmills commented Feb 16, 2022

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

@bcmills
Copy link
Contributor

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
Contributor

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

@bcmills bcmills modified the milestones: Go1.19, Go1.20 Jun 30, 2022
@bcmills bcmills modified the milestones: Go1.20, Go1.21 Dec 12, 2022
@gopherbot gopherbot removed this from the Go1.21 milestone Aug 8, 2023
@gopherbot gopherbot added this to the Go1.22 milestone Aug 8, 2023
@bcmills bcmills modified the milestones: Go1.22, Go1.23 Dec 8, 2023
@bcmills bcmills removed their assignment Mar 11, 2024
@bcmills bcmills added BadErrorMessage Issues related compiler error messages that should be better. GoCommand cmd/go labels Mar 11, 2024
@bcmills bcmills modified the milestones: Go1.23, Backlog Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BadErrorMessage Issues related compiler error messages that should be better. GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

9 participants