Skip to content

cmd/compile: confusing message when go.mod file and vendor folder both present #44149

Closed

Description

@dotaheor

What version of Go are you using (go version)?

$ go version
go version go1.15.8 linux/amd64
go version go1.16rc1 linux/amd64

What did you do?

package main

import _ "aaa"

func main() {
}

What did you expect to see?

package aaa is not in GOROOT (GOROOT/src/aaa)

What did you see instead?

cannot find package "." in:
	ProjectRoot/vendor/aaa

Activity

  1. seankhliao commented on Feb 7, 2021

    @seankhliao
    Member

    What exactly did you do, I can't reproduce the issue as described

    Also note that names without a dot in the first element are considered reserved for the standard library, using a proper name gives a better error message

    » mkdir /tmp/example && cd /tmp/example
    
    » go mod init example.com/foo
    go: creating new go.mod: module example.com/foo
    
    » cat << EOF > main.go
    package main
    import _ "aaa"
    func main() {}
    EOF
    
    » go build
    main.go:3:8: package aaa is not in GOROOT (/home/arccy/sdk/gotip/src/aaa)
    
    » mkdir vendor
    
    » go build
    main.go:3:8: cannot find package "." in:
    	/tmp/example/vendor/aaa
  2. added
    WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.
    on Feb 7, 2021
  3. dotaheor commented on Feb 8, 2021

    @dotaheor
    Author

    You exactly reproduced the error described above.

  4. seankhliao commented on Feb 8, 2021

    @seankhliao
    Member

    I don't think it's a problem? Without vendor/ a package with a name like aaa cannot be retrieved by standard tooling so it makes sense to report it as not found in GOROOT. With vendor/, which can be created by other tools, it is possible to use a package named like that

  5. dotaheor commented on Feb 8, 2021

    @dotaheor
    Author

    OK, but shouldn't the message be

    cannot find package "aaa" in:
    	ProjectRoot/vendor
    

    package "." confuses people.

  6. seankhliao commented on Feb 8, 2021

    @seankhliao
    Member

    that's #38748

  7. dotaheor commented on Feb 8, 2021

    @dotaheor
    Author

    Looks so. Close it for that.

  8. locked and limited conversation to collaborators on Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions