constabulary / gb

gb, the project based build tool for Go
https://getgb.io/
MIT License
2.15k stars 148 forks source link

Go 1.7rc1 - can't find import: "golang.org/x/net/http2/hpack" #635

Closed unrolled closed 8 years ago

unrolled commented 8 years ago

I've added https://github.com/sideshow/apns2 as a vendor to my project, which in turn requires golang.org/x/net/http2. Everything builds properly in Go 1.6.2. I installed Go 1.7rc1 (via brew install go --devel), and now I receive this error frame.go:17: can't find import: "golang.org/x/net/http2/hpack". I've tried updating my vendors and gb, but nothing seems to help.

$ env DEBUG=. gb build

2016/07/12 08:31:25 cmd.go:82: project root "/Users/cory/code/unrolled/ecw/api"
2016/07/12 08:31:25 depfile.go:185: loading depfile at "/Users/cory/code/unrolled/ecw/api/depfile"
2016/07/12 08:31:25 depfile.go:33: no depfile, nothing to do.
2016/07/12 08:31:25 match.go:18: /Users/cory/code/unrolled/ecw/api ..
2016/07/12 08:31:25 match.go:108: matchPackages: ...
2016/07/12 08:31:25 main.go:118: args: [app config cron cron/airindex cron/alerts cron/hourly cron/radar cron/radaroutages cron/weather handlers middleware models stats utilities]
2016/07/12 08:31:26 install.go:70: /Users/cory/code/unrolled/ecw/api/pkg/darwin-amd64/golang.org/x/net/http2.a is missing
2016/07/12 08:31:26 context.go:309: cd /Users/cory/code/unrolled/ecw/api/vendor/src/golang.org/x/net/http2; [/usr/local/Cellar/go/1.7rc1/libexec/pkg/tool/darwin_amd64/compile -p golang.org/x/net/http2 -pack -o /var/folders/z3/3jtkpww516v63hmn5q8xc2s40000gn/T/gb901701484/golang.org/x/net/http2.a -I /var/folders/z3/3jtkpww516v63hmn5q8xc2s40000gn/T/gb901701484 -I /Users/cory/code/unrolled/ecw/api/pkg/darwin-amd64 -complete client_conn_pool.go configure_transport.go errors.go fixed_buffer.go flow.go frame.go go16.go go17.go gotrack.go headermap.go http2.go pipe.go server.go transport.go write.go writesched.go]
# golang.org/x/net/http2
frame.go:17: can't find import: "golang.org/x/net/http2/hpack"
FATAL: command "build" failed: exit status 2
2016/07/12 08:31:26 context.go:288: removing work directory: /var/folders/z3/3jtkpww516v63hmn5q8xc2s40000gn/T/gb901701484

$ gb env

GB_PROJECT_DIR="/Users/cory/code/unrolled/ecw/api"
GB_SRC_PATH="/Users/cory/code/unrolled/ecw/api/src:/Users/cory/code/unrolled/ecw/api/vendor/src"
GB_PKG_DIR="/Users/cory/code/unrolled/ecw/api/pkg/darwin-amd64"
GB_BIN_SUFFIX="-darwin-amd64"
GB_GOROOT="/usr/local/Cellar/go/1.7rc1/libexec"

$ go env

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/cory/gocode"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7rc1/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7rc1/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/z3/3jtkpww516v63hmn5q8xc2s40000gn/T/go-build663616406=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
YvanDaSilva commented 8 years ago

@unrolled This is not related to GB but to Go 1.7rc1 See : https://github.com/golang/go/issues/16333 If you compile the last version it should be "solved" << with a hack if you look at that issue resolution.

YvanDaSilva commented 8 years ago

@davecheney As mentioned on https://github.com/golang/go/issues/16333#issuecomment-232977002

The new fix for Go 1.7 will in fact trigger a "bug" in GB with "_" not being allowed in the following regex : https://github.com/constabulary/gb/blob/4ffaea660a4e178e62e94fb8447fb43039ceb1e8/internal/vendor/repo.go#L72

kevinburke commented 8 years ago

I get this same issue trying to vendor most new libraries.

Steps to reproduce:

1) Download and compile go1.7rc3. I'm using a Mac, but I am guessing this error can be reproduced on any machine.

2) Recompile gb using the new go1.7rc3

3) Create a new GOPATH and src dir - not sure whether this is necessary, but did it to isolate the code.

```bash
mkdir /tmp/new-gopath
pushd /tmp/new-gopath
    mkdir src
    export GOPATH=$(PWD)
popd

4) Run `gb vendor fetch github.com/vektra/mockery`. This fails with an error; here's the output I get.
$ gb vendor fetch github.com/vektra/mockery
fetching recursive dependency github.com/vektra/errors
fetching recursive dependency golang.org/x/tools/go/loader
fetching recursive dependency golang.org/x/tools/go/ast/astutil
fetching recursive dependency golang.org/x/tools/go/buildutil

fetching recursive dependency golang.org/x/tools/imports
fetching recursive dependency golang_org/x/net/http2/hpack
FATAL: command "fetch" failed: "golang_org/x/net/http2/hpack" is not a valid import path
FATAL: command "vendor" failed: exit status 1

Here's the state of the manifest and the tree after that's complete: https://gist.github.com/kevinburke/6fbddb351bdfbd902e904bfb4084ebd1

Note also if you try to run it again, `gb` insists all packages have been downloaded, even though several are missing.

$ gb vendor fetch github.com/vektra/mockery FATAL: command "fetch" failed: github.com/vektra/mockery is already vendored FATAL: command "vendor" failed: exit status 1

kevinburke commented 8 years ago

I just tried downloading/compiling gb with Go 1.6.3, then rerunning gb vendor fetch, and still ran into the same problem.

kevinburke commented 8 years ago

FWIW, here's a patch to make version reporting easier: https://github.com/constabulary/gb/pull/639

davecheney commented 8 years ago

Thank you for reporting this issue.

The problem is caused by golang/go@4d00937 which renamed $GOROOT/src/vendor/golang.org to golang_org to fix golang/go#16333

The solution is not to change the regex, but to add enough support for vendor/ to gb to be able to pick up the vendored copy of the net/http2 packages from $GOROOT.

davecheney commented 8 years ago

wrt.

Note also if you try to run it again, gb insists all packages have been downloaded, even though several are missing.

$ gb vendor fetch github.com/vektra/mockery
FATAL: command "fetch" failed: github.com/vektra/mockery is already vendored
FATAL: command "vendor" failed: exit status 1

This is technically correct, vektra/mockery has been written to the manifest file, but it's cold comfort because you'll need to vendor each extra dependency by hand (or remove vektra/mockery) and fetch it again.

brendandburns commented 8 years ago

Is there a good way to fix this? I'm still seeing this with go 1.7 and gb from head...

davecheney commented 8 years ago

It should be fixed in tip. If you've upgraded go make sure you rebuild gb.

On 26 Sep. 2016, at 13:47, Brendan Burns notifications@github.com wrote:

Is there a good way to fix this? I'm still seeing this with go 1.7 and gb from head...

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

brendandburns commented 8 years ago

Thanks for the quick reply.

I did a go get github.com/constabulary/gb into a fresh GOPATH so I think I'm ok, but I'll check my path and try again...

brendandburns commented 8 years ago

Yeah, I'm still seeing this and I believe I'm correctly installed. Is there a way to get gb to kick out the version that it thinks it is running on?

(do I need to re-vendor the dependency?)

davecheney commented 8 years ago

nope, gb doesn't have a version command, sorry, it's a long story.

On Mon, Sep 26, 2016 at 2:03 PM, Brendan Burns notifications@github.com wrote:

Yeah, I'm still seeing this and I believe I'm correctly installed. Is there a way to get gb to kick out the version that it thinks it is running on?

(do I need to re-vendor the dependency?)

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/constabulary/gb/issues/635#issuecomment-249475019, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA0nsr6GvZ8ZxdmuDqO-vg_KCbGtvks5qt0QAgaJpZM4JKes- .

davecheney commented 8 years ago

The sad story of a version number is #595

The easiest solution would be to remove gb and gb-vendor wherever you find them in you path and do a go get -u -v github.com/constabulary/gb/...

brendandburns commented 8 years ago

ah, I re-built gb but not gb-vendor, perhaps the problem...

brendandburns commented 8 years ago

(might I suggest at least a --verbose flag that logs the current git commit, precisely for use-cases like this, even if you are far from 1.0)

davecheney commented 8 years ago

I hope that is the problem. It's taking me a while to page back in the details of that bug

On Mon, 26 Sep 2016, 14:28 Brendan Burns notifications@github.com wrote:

ah, I re-built gb but not gb-vendor, perhaps the problem...

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/constabulary/gb/issues/635#issuecomment-249477109, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA4AssDcejt6ZtcjS9eME0QuZFhiwks5qt0n9gaJpZM4JKes- .

davecheney commented 8 years ago

The problem is, how to do that inside the framework of the go tool.

I don't want to go down the route, just yet, of adding makefilea or othrt wrappers as that will increase the support burden from non unix users.

On Mon, 26 Sep 2016, 14:29 Brendan Burns notifications@github.com wrote:

(might I suggest at least a --verbose flag that logs the current git commit, precisely for use-cases like this, even if you are far from 1.0)

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/constabulary/gb/issues/635#issuecomment-249477184, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA4E0ytjbQfZRy-jAZ9PJbNe_lMmrks5qt0o3gaJpZM4JKes- .

brendandburns commented 8 years ago

sorry to drag you back into the bug, but I can't seem to get this to work, here's a repro:

git clone https://github.com/metaparticle-io/container-lib.git
cd container-lib/sharder
gb build all

If that works for you, then clearly my dev environment is borked somehow...

davecheney commented 8 years ago

@brendandburns that worked fine for me at tip.

Which version of Go are you using? On the off chance that you are using 1.7rc1 you'll have to move off that version as that broke not just gb, but go packages using external repos

thomasmodeneis commented 8 years ago

Right, I'm facing similar issue but with golang.org/x/net/http2.

../../server.go:50:2: cannot find package "golang.org/x/net/http2" in any of:
        /usr/local/go/src/golang.org/x/net/http2 (from $GOROOT)

and I'm on: go1.7.1 darwin/amd64 From what I could understand from @davecheney "quote":

The problem is caused by golang/go@4d00937 which renamed $GOROOT/src/vendor/golang.org to golang_org to fix golang/go#16333

and second quote: On the off chance that you are using 1.7rc1 you'll have to move off that version as that broke not just gb, but go packages using external repos

Sorry but this is a bit confused and gets me a little worried about the actual state of go package management. :|

Sometimes, people like me comes to opened issues, asking about something else that is not exactly what the defect is about, but is related and I appologise for this, however because the problem seems very similar, I understand that the question is pertinent to the topic, so I hope you guys don't mind it.

When I try to go get the golang.org/x/net/http2, I'm running into:

$ go get golang.org/x/net/http2
# cd /opt/gocode/src/golang.org/x/net; git pull --ff-only
From https://go.googlesource.com/net
   cf4effb..6dba816  master     -> origin/master
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.

    git pull <remote> <branch>

package golang.org/x/net/http2: exit status 1

Sorry but this error is really unclear, any ideas ?

This is my go env

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/opt/gocode"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

I feel like there is something broken and people are not being told about it, perhaps we should advise people about this a bit better ?

Thanks and sorry to disturb.

davecheney commented 8 years ago

Right, I'm facing similar issue but with golang.org/x/net/http2. ../../server.go:50:2: cannot find package "golang.org/x/net/http2" in any of: /usr/local/go/src/golang.org/x/net/http2 (from $GOROOT) and I'm on: go1.7.1 darwin/amd64

Is this related to gb, or the go tool. If it's gb can you please open a new issue with the output of running the relevant command with env DEBUG=. set.

From what I could understand from @davecheney "quote": The problem is caused by golang/go@4d00937 which renamed $GOROOT/src/vendor/golang.org to golang_org to fix golang/go#16333 and second quote:

My comment related to the way the vendor/ support, when used in the standard library shadows any matching package in a users GOPATH. This does not affect gb, gb does not use `GOPATH.

On the off chance that you are using 1.7rc1 you'll have to move off that version as that broke not > just gb, but go packages using external repos

You need to move off 1.7rc1, it is not production quality.

Sorry but this is a bit confused and gets me a little worried about the actual state of go package management. :|

Yes, it's a mess.

Sometimes, people like me comes to opened issues, asking about something else that is not exactly what the defect is about, but is related and I appologise for this, however because the problem seems very similar, I understand that the question is pertinent to the topic, so I hope you guys don't mind it.

Hopefully I've answer your question. If it's related to the go tool, i'm sorry I cannot help you here. If it's related to gb, I recommend opening a new issue.

When I try to go get the golang.org/x/net/http2, I'm running into:

$ go get golang.org/x/net/http2

`; git pull --ff-only

From https://go.googlesource.com/net cf4effb..6dba816 master -> origin/master You are not currently on a branch. Please specify which branch you want to merge with. See git-pull(1) for details.

git pull

package golang.org/x/net/http2: exit status 1 Sorry but this error is really unclear, any ideas ?

This looks like the go tool, something has moved your copy of /opt/gocode/src/golang.org/x/net into a disconnected head state. Remove the directory and try again.

Update: I've managed to work around the issue, and it was pretty much what I had to do other times for 1.4,1.5,1.6,1.7 .... delete all the go packages and start it over go getting one by one. I feel like there is something broken and people are not being told about it, perhaps we should advise people about this a bit better ?

You shouldn't have to do this. This problem looks like a problem with the go tool, not gb, please raise an issue on https://github.com/golang/go.

davecheney commented 8 years ago

I'm going to close this issue for the moment. I'm pretty sure the workaround in place should work.

PLEASE if anyone else has this problem, please raise a new issue so we have a clean chain of debugging information.

I'm going to lock this issue to ensure this happens. Thank you for your understanding.