You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/go: no helpful error message for "no Go files" with modules #27122
Note that this relatively unhelpful error message still occurs with 1.11.4 and 1.12beta1.
# Failing example. There are no .go files (and hence no package) in the same directory
# as the main `go.mod` file.
mkdir -p /tmp/scratchpad/bitbucket-module-bad
cd /tmp/scratchpad/bitbucket-module-bad
go mod init bitbucket.org/foo/bar
mkdir baz
cat <<EOF > baz/baz.go
package baz
func Hello() string { return "Hello from bitbucket.org/foo/bar/baz" }
EOF
cd /tmp/scratchpad/bitbucket-module-bad
go build -v
Fails with:
$ go build -v
Fetching https://bitbucket.org?go-get=1
Parsing meta tags from https://bitbucket.org?go-get=1 (status code 200)
can't load package: package bitbucket.org/foo/bar: unknown import path "bitbucket.org/foo/bar":
cannot find module providing package bitbucket.org/foo/bar
One solution (as covered in an FAQ on the modules wiki) is go build ./... or other variations.
I have been writing Go (it was the first language I really learned well) and so ./... seemed normal to me, but I was recently helping a very experienced C# engineer on board onto my team. We were pair-programming and we came across this issue and I used go install ./... and he was a little weirded out but thought it was easy to remember but was unintuitive.
Perhaps ./... could be the default if GO111MODULE=on or there's a go.mod file in the current directory?
Failing that, the error message could use some work. can't load package: package projectname: unknown import path "projectname": cannot find module providing package projectname doesn't suggest to me "You forgot to specify which module to compile, maybe with ./...".
Reacted by thepudds, Doru Carastan, Alex North and pepa65
I was following a tutorial for something (gRPC) and the tutorial makes use of modules, so I got to learn about them too \o/
However I had an issue where I had made a mistake and the error message from go build was not very helpful.
Below is pasted the file tree, the root go.mod, the code that was generating the error, the command being executed and the error message. The error turned out to be that the import path was pointed at a directory with no go source files, but the error reported was "cannot find module providing package"
~/src/golang.org/x/build$ gotip version
go version devel +0915a19a Fri Dec 6 05:12:15 2019 +0000 linux/amd64
~/src/golang.org/x/build$ GO111MODULE=on gotip build ./vcs-test
can't load package: package ./vcs-test: no Go files in /usr/local/google/home/bcmills/src/golang.org/x/build/vcs-test
~/src/golang.org/x/build$ GO111MODULE=off gotip build ./vcs-test
can't load package: package golang.org/x/build/vcs-test: no Go files in /usr/local/google/home/bcmills/src/golang.org/x/build/vcs-test
Activity
thepudds commentedon Dec 28, 2018
Note that this relatively unhelpful error message still occurs with 1.11.4 and 1.12beta1.
Fails with:
One solution (as covered in an FAQ on the modules wiki) is
go build ./...or other variations.CC @myitcv @bcmills @heschik
hyangah commentedon Dec 28, 2018
#29268 is related.
crhntr commentedon Dec 30, 2018
I have been writing Go (it was the first language I really learned well) and so
./...seemed normal to me, but I was recently helping a very experienced C# engineer on board onto my team. We were pair-programming and we came across this issue and I usedgo install ./...and he was a little weirded out but thought it was easy to remember but was unintuitive.lpar commentedon Jan 28, 2019
Perhaps
./...could be the default ifGO111MODULE=onor there's ago.modfile in the current directory?Failing that, the error message could use some work.
can't load package: package projectname: unknown import path "projectname": cannot find module providing package projectnamedoesn't suggest to me "You forgot to specify which module to compile, maybe with ./...".thepudds commentedon Apr 8, 2019
#31270 might be a dup of this.
shaneHowearth commentedon May 31, 2019
I was following a tutorial for something (gRPC) and the tutorial makes use of modules, so I got to learn about them too \o/
However I had an issue where I had made a mistake and the error message from
go buildwas not very helpful.Below is pasted the file tree, the root go.mod, the code that was generating the error, the command being executed and the error message. The error turned out to be that the import path was pointed at a directory with no go source files, but the error reported was "cannot find module providing package"
gopherbot commentedon Jul 9, 2019
Change https://golang.org/cl/185345 mentions this issue:
cmd/go: rationalize errors in internal/load and internal/modloadbcmills commentedon Dec 6, 2019
This appears to be fixed at head.
cmd/go: rationalize errors in internal/load and internal/modload