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: misleading 'use of internal package not allowed' in GOPATH mode when a subtree vendors its own package #34558

Open
srinivas-kandula opened this issue Sep 26, 2019 · 7 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@srinivas-kandula
Copy link

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

$ go version
go version go1.12.7 linux/amd64

Does this issue reproduce with the latest release?

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

RHEL 8 (Ootpa)

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/srinivas/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/srinivas/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build192096706=/tmp/go-build -gno-record-gcc-switches"

Dep version
dep:
version : v0.5.4
build date :
git hash :
go version : go1.12.7
go compiler : gc
platform : linux/amd64
features : ImportDuringSolve=false

What did you do?

git clone https://github.com/wavefrontHQ/wavefront-kubernetes-collector.git
cd wavefrontHQ/wavefront-kubernetes-collector
dep ensure
make

What did you expect to see?

I was expecting the build to be successful

What did you see instead?

go vet -composites=false ./...
cmd/test-driver/main.go:13:2: use of internal package github.com/wavefrontHQ/wavefront-kubernetes-collector/vendor/github.com/wavefronthq/wavefront-kubernetes-collector/internal/options not allowed
cmd/wavefront-collector/main.go:21:2: use of internal package github.com/wavefrontHQ/wavefront-kubernetes-collector/vendor/github.com/wavefronthq/wavefront-kubernetes-collector/internal/agent not allowed
cmd/wavefront-collector/main.go:22:2: use of internal package github.com/wavefrontHQ/wavefront-kubernetes-collector/vendor/github.com/wavefronthq/wavefront-kubernetes-collector/internal/configuration not allowed
@bcmills
Copy link
Contributor

bcmills commented Sep 26, 2019

dep ensure is not part of the go command.

It sounds like dep ensure is for some reason copying packages already within your repo into its own vendor directory. If that is the case, then the go command could perhaps give a better error message, although since it likely only occurs in GOPATH mode we're unlikely to prioritize a fix.

Have you tried it with the latest Go release (1.13.1)? Does it still reproduce, and if so is the error message any more useful?

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 26, 2019
@bcmills bcmills added this to the Unplanned milestone Sep 26, 2019
@srinivas-kandula
Copy link
Author

Getting same error message with go version go1.13.1 linux/amd64

go vet -composites=false ./...
cmd/test-driver/main.go:13:2: use of internal package github.com/wavefrontHQ/wavefront-kubernetes-collector/vendor/github.com/wavefronthq/wavefront-kubernetes-collector/internal/options not allowed
cmd/wavefront-collector/main.go:21:2: use of internal package github.com/wavefrontHQ/wavefront-kubernetes-collector/vendor/github.com/wavefronthq/wavefront-kubernetes-collector/internal/agent not allowed

@bcmills
Copy link
Contributor

bcmills commented Sep 26, 2019

@srinivas-kandula, can you confirm whether your repo's top-level vendor directory contains copies of packages defined within that repo?

@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Sep 26, 2019
@srinivas-kandula
Copy link
Author

srinivas-kandula commented Sep 26, 2019

@bcmills Appreciate your quick replies.. yup it contains those directories.
My top level dir:

$ ls
cmd  deploy  docs  Gopkg.lock  Gopkg.toml  internal  LICENSE  Makefile  open_source_licenes.txt  plugins  README.md  vendor

Vendor directory
/go/src/github.com/wavefrontHQ/wavefront-kubernetes-collector/vendor/github.com/wavefronthq/wavefront-kubernetes-collector

 $ls
internal  LICENSE  plugins

@bcmills bcmills changed the title use of internal package not allowed error cmd/go: misleading 'use of internal package not allowed' in GOPATH mode when a subtree vendors its own package Sep 26, 2019
@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Sep 26, 2019
@bcmills
Copy link
Contributor

bcmills commented Sep 26, 2019

The fix on the go side is a better diagnostic. modload.AmbiguousImportError seems appropriate, except that it's not obvious to me that the package in a position to detect this error has access to that declaration and there are not actually any modules involved.

(Probably this will just be closed when GOPATH mode is deprecated, but you're welcome to close it earlier if you like, or contribute a short-lived fix if it is not too invasive.)

@srinivas-kandula
Copy link
Author

I think the real issue is with dep, i am fine to close this issue. Kindly let me know if you have any workarounds/suggestions to overcome this issue?

@bcmills
Copy link
Contributor

bcmills commented Sep 26, 2019

As a workaround, you could rm -r vendor/github.com/wavefronthq/wavefront-kubernetes-collector after you run dep ensure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants