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

Comments

@srinivas-kandula
Copy link

commented Sep 26, 2019

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

This comment has been minimized.

Copy link
Member

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 this to the Unplanned milestone Sep 26, 2019
@srinivas-kandula

This comment has been minimized.

Copy link
Author

commented Sep 26, 2019

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

This comment has been minimized.

Copy link
Member

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?

@srinivas-kandula

This comment has been minimized.

Copy link
Author

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 and removed WaitingForInfo labels Sep 26, 2019
@bcmills

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

commented Sep 26, 2019

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

This comment has been minimized.

Copy link
Member

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
Projects
None yet
2 participants
You can’t perform that action at this time.