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: go get <current package> gives arcane error #54745

Open
MaerF0x0 opened this issue Aug 29, 2022 · 2 comments
Open

cmd/go: go get <current package> gives arcane error #54745

MaerF0x0 opened this issue Aug 29, 2022 · 2 comments
Labels
GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@MaerF0x0
Copy link

MaerF0x0 commented Aug 29, 2022

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

go version
go version go1.18.5 darwin/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/$ME/Library/Caches/go-build"
GOENV="/Users/$ME/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/$ME/dev/pkg/mod"
GONOPROXY="github.com/$EMPLOYER*"
GONOSUMDB="github.com/$EMPLOYER*"
GOOS="darwin"
GOPATH="/Users/$ME/dev"
GOPRIVATE="github.com/$EMPLOYER*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.18.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.18.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/$ME/dev/src/github.com/$EMPLOYER/$REPO/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/lx/c2s6byr55blfmt03c9zhhmv00000gn/T/go-build3003361518=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

was trying a command in the wrong cwd and the error lead me to think my command was wrong, not the directory... An updated output could help.

cd $GOPATH/src/github.com/$EMPLOYER/$REPO
go get github.com/$EMPLOYER/$REPO

-->

go get github.com/$EMPLOYER/$REPO
go: github.com/$EMPLOYER/$REPO: invalid github.com import path "github.com/$EMPLOYER"

go get  github.com/$EMPLOYER/$REPOT@latest
go: can't request version "latest" of the main module (github.com/$EMPLOYER/$REPO)

What did you expect to see?

I presume this is because you cannot import a module into itself? If so it might be helpful to emit a message that indicates a hint that you cannot do that
eg:

go get github.com/$EMPLOYER/$REPO
go: github.com/$EMPLOYER/$REPO: cannot import module into itself

go get  github.com/$EMPLOYER/$REPO@latest
go: github.com/$EMPLOYER/$REPO: cannot import module into itself

What did you see instead?

go: github.com/segmentio/personas-utils: invalid github.com import path "github.com/$EMPLOYER"

go: can't request version "latest" of the main module (github.com/$EMPLOYER/$REPO)

Happy to help with a PR if we agree this is would be a good change.

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Aug 29, 2022
@seankhliao
Copy link
Member

cc @bcmills

@bcmills
Copy link
Contributor

bcmills commented Aug 29, 2022

I don't think that cannot import module into itself is a good error message: import statements refer to packages, not modules, and the arguments to go get are in general also packages rather than modules (when possible).

That said, I agree that the existing error messages are also confusing. If you can figure out where the invalid github.com import path error message is coming from, probably we should just get rid of it? (Kind of depends on where it's coming from and what we might be able to replace it with.)

The can't request version "latest" of the main module error message seems close to correct — but may it's confusing because the "latest" string is implicit in this case? But it also seems odd to me to use a complete path to update the dependencies of the package in the CWD, when that is more easily expressed as go get .. 🤔

@bcmills bcmills added this to the Backlog milestone Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go 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

3 participants