hashicorp / vault

A tool for secrets management, encryption as a service, and privileged access management
https://www.vaultproject.io/
Other
30.81k stars 4.17k forks source link

cannot find package "golang.org/x/tools/cmd/vet" #1310

Closed jonathanpdx closed 8 years ago

jonathanpdx commented 8 years ago

I'm trying to build the current version of vault from master (git clone https://github.com/hashicorp/vault). I read the README.md file and tried:

(testing)ip-192-168-0-111:vault testuser$ export GOPATH=`pwd`
(testing)ip-192-168-0-111:vault testuser$ export PATH=$GOPATH/bin:$PATH
(testing)ip-192-168-0-111:vault testuser$ make bootstrap
Installing github.com/mitchellh/gox
Installing golang.org/x/tools/cmd/cover
Installing golang.org/x/tools/cmd/vet
package golang.org/x/tools/cmd/vet: cannot find package "golang.org/x/tools/cmd/vet" in any of:
        /usr/local/go/src/golang.org/x/tools/cmd/vet (from $GOROOT)
        /Users/testuser/work/go/src/github.com/hashicorp/vault/src/golang.org/x/tools/cmd/vet (from $GOPATH)
make: *** [bootstrap] Error 1

I'm new to Go so perhaps there's something I'm missing. I was under the impression that all the dependencies would be auto-installed.

jefferai commented 8 years ago

@jonathanpdx My guess is that it was some kind of transient network error?

Honestly, I'm not sure -- make bootstrap simply does a go get on the tools listed. So go get should go fetch those tools from the network if they're not already local. My guess is that that network fetching failed, so it fell back to trying to find it locally, and couldn't.

jefferai commented 8 years ago

You can also just run go get golang.org/x/tools/cmd/vet manually.

tomalok commented 8 years ago

vet appears to be included in go itself now, and they must've cleaned out some cobwebs on the download site. I fixed the problem by excluding the vet source from EXTERNAL_TOOLS - worked fine.

make EXTERNAL_TOOLS="github.com/mitchellh/gox golang.org/x/tools/cmd.cover" bootstrap dev

jefferai commented 8 years ago

Glad it's working!

tomalok commented 8 years ago
diff --git a/Makefile b/Makefile
index 0c71498..dc2d863 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,7 @@ TEST?=$$(go list ./... | grep -v /vendor/)
 VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr
 EXTERNAL_TOOLS=\
        github.com/mitchellh/gox \
-       golang.org/x/tools/cmd/cover \
-       golang.org/x/tools/cmd/vet
+       golang.org/x/tools/cmd/cover

 default: test
DustinChaloupka commented 8 years ago

Should the Makefile have vet removed from the EXTERNAL_TOOLS by default? Vault requires go1.6+ which does include vet by default.

jefferai commented 8 years ago

It doesn't matter either way as leaving it in there doesn't cause an error. But feel free to submit a PR removing it if you like.

tomalok commented 8 years ago

leaving it as it is now does cause an error, which is why i posted the diff, above... it had been working about two weeks ago, but something changed over at golang.org/x/tools/cmd/vet -- seems they did some cleanup. my Dockerfile attempts to build against the 0.5.2 branch, but the same thing happens with the master branch:

Step 6 : RUN /bootstrap.sh
 ---> Running in cfad3c8cafb7
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
(1/2) Upgrading musl (1.1.12-r4 -> 1.1.12-r5)
(2/2) Upgrading musl-utils (1.1.12-r4 -> 1.1.12-r5)
Executing busybox-1.24.1-r7.trigger
OK: 5 MiB in 11 packages
(1/7) Installing openssl (1.0.2g-r0)
(2/7) Installing ca-certificates (20160104-r2)
(3/7) Installing libssh2 (1.6.0-r1)
(4/7) Installing curl (7.47.0-r0)
(5/7) Installing expat (2.1.0-r2)
(6/7) Installing pcre (8.38-r0)
(7/7) Installing git (2.6.6-r0)
Executing busybox-1.24.1-r7.trigger
Executing ca-certificates-20160104-r2.trigger
OK: 22 MiB in 18 packages
Cloning into '/tmp/go/src/github.com/hashicorp/vault'...
(1/8) Installing ncurses-terminfo-base (6.0-r6)
(2/8) Installing ncurses-terminfo (6.0-r6)
(3/8) Installing ncurses-libs (6.0-r6)
(4/8) Installing readline (6.3.008-r4)
(5/8) Installing bash (4.3.42-r3)
Executing bash-4.3.42-r3.post-install
(6/8) Installing binutils-libs (2.25.1-r0)
(7/8) Installing binutils (2.25.1-r0)
(8/8) Installing make (4.1-r0)
Executing busybox-1.24.1-r7.trigger
OK: 39 MiB in 26 packages
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
(1/1) Installing go (1.6-r1)
Executing busybox-1.24.1-r7.trigger
OK: 223 MiB in 27 packages
Installing github.com/mitchellh/gox
Installing golang.org/x/tools/cmd/cover
Installing golang.org/x/tools/cmd/vet
package golang.org/x/tools/cmd/vet: cannot find package "golang.org/x/tools/cmd/vet" in any of:
    /usr/lib/go/src/golang.org/x/tools/cmd/vet (from $GOROOT)
    /tmp/go/src/golang.org/x/tools/cmd/vet (from $GOPATH)
Makefile:56: recipe for target 'bootstrap' failed
make: *** [bootstrap] Error 1

It's basically failing to pull golang.org/x/tools/cmd/vet and thus it can't find it in GOROOT or GOPATH.

Sorry, didn't have time to figure out my first GitHub pull request for what's essentially a one-line (plus one-char) diff. I'll sort that out if it's an issue.

jefferai commented 8 years ago

I couldn't repeat your error, which is why I'm ambivalent about the change. I'm not convinced it has anything to do with vet being included in Go now. It's perfectly valid to have newer versions of tools that live in your gopath, and the error you are getting is a not found error, not something that indicates that it is the result of a conflict.

I don't know why you can't pull the package, but when I repeat your command I simply get the source pulled into my gopath and a newer local version built.

tomalok commented 8 years ago

Attached is vault-issue-1310.zip which contains a Dockerfile with which you can replicate the issue in a fresh build environment by running

docker build .

To illustrate that having golang.org/x/tools/cmd/vet in EXTERNAL_TOOLS is the culprit, replace bootstrap.sh with bootstrap-works.sh (which explicitly removes vet from the list of external tools to install) and try do the docker build . again.

If go 1.6+ includes vet and if Vault requires 1.6+ to build, then it shouldn't be included in EXTERNAL_TOOLS.

wsh commented 8 years ago

I'm also seeing this issue on master and removing the explicit vet get fixed it.

jefferai commented 8 years ago

@wsh Is this also in Docker? I still can't reproduce it, although I've only tested outside of Docker. For me, the command succeeds normally, placing an updated vet binary in my GOPATH.

wsh commented 8 years ago

Sorry, @jefferai, I should have been explicit--this is just on my vanilla OS X workstation. go get golang.org/x/tools/cmd/vet fails, too. https://github.com/joefitzgerald/go-plus/issues/232 looks related.

jefferai commented 8 years ago

Very strange.

BRMatt commented 8 years ago

I'm also seeing this when trying to build vault on go 1.6, in a brand new GOPATH that contains only vault:

make bootstrap dev
Installing github.com/mitchellh/gox
Installing golang.org/x/tools/cmd/cover
Installing golang.org/x/tools/cmd/vet
package golang.org/x/tools/cmd/vet: cannot find package "golang.org/x/tools/cmd/vet" in any of:
    /usr/local/go/src/golang.org/x/tools/cmd/vet (from $GOROOT)
    /home/ubuntu/fpm-recipes/vault/tmp-build/golang/src/golang.org/x/tools/cmd/vet (from $GOPATH)
make[1]: *** [bootstrap] Error 1
make[1]: Leaving directory `/home/ubuntu/fpm-recipes/vault/tmp-build/golang/src/github.com/hashicorp/vault'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/fpm-cookery-0.27.0/lib/fpm/cookery/utils.rb:12:in `safesystem': 'system(["make", "bootstrap", "dev"])' failed with error code: 2 (RuntimeError)
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/fpm-cookery-0.27.0/lib/fpm/cookery/utils.rb:55:in `make'
    from /home/ubuntu/fpm-recipes/vault/recipe.rb:45:in `block in build'
    from /home/ubuntu/fpm-recipes/vault/recipe.rb:44:in `chdir'
    from /home/ubuntu/fpm-recipes/vault/recipe.rb:44:in `build'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/fpm-cookery-0.27.0/lib/fpm/cookery/packager.rb:114:in `block (2 levels) in dispense'
jefferai commented 8 years ago

@BRMatt Very strange.