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 "missing dot in first path element" when importing missing package #35273

Closed
a8m opened this issue Oct 31, 2019 · 4 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@a8m
Copy link
Contributor

a8m commented Oct 31, 2019

This issue was created as a follow-up to my comment in #34769 and CL 203118.

When running go build on a module foo, that imports a local module bar without a package (no Go files), the returned error is:

build foo: cannot load bar: malformed module path "bar": missing dot in first path 
element

CL 203118 changes the module importer to print more friendly error as:

main.go:3:8: module bar@ found (v0.0.0-00010101000000-000000000000, replaced by ../bar), 
but does not contain package

Full example exists here: https://github.com/a8m/go-issue-34769


If you ask yourself why creating a module without any Go files (the bar module), well, we tried to build a few Docker images and accidentally forgot to copy some of the Go files to the image. It took us hours to figure out what the "missing dot in first path element" means in this case.

@a8m a8m changed the title cmd/go: bad error when a module does not contain a package cmd/go: bad error on import empty local modules Oct 31, 2019
@gopherbot
Copy link

Change https://golang.org/cl/203118 mentions this issue: cmd/go/internal/modload: fail if no package was found in local module

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Nov 5, 2019
@bcmills bcmills added this to the Backlog milestone Nov 5, 2019
@jayconrod jayconrod changed the title cmd/go: bad error on import empty local modules cmd/go: confusing error "missing dot in first path element" when importing missing package Nov 5, 2019
@aayushrathore
Copy link

aayushrathore commented Nov 7, 2019

for me the issue was resolved after changing the GOROOT environment variable from "/usr/loca/go/bin" to "/usr/local/go"

OS : Linux centos

@gopherbot
Copy link

Change https://golang.org/cl/205878 mentions this issue: cmd/go/internal/modload: improve error when a missing package has a replaced-but-unfetchable module as a prefix

@Peakchen
Copy link

at windows,how to solve?

@golang golang locked and limited conversation to collaborators Jul 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules 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

5 participants