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 test" cannot resolve external dependencies within src directory #18606
Comments
The underscore in the package name reported by the go tool says you haven't set GOPATH correctly. Sorry, you have to live in GOPATH's world if you want to use the go tool. |
I thought my GOPATH is set. My go env says it is set to "GOPATH="/Users/builduser/Projects/golang" |
The fact that go get worked says to me that you to have GOPATH set, but you're trying to use the go tool to build code that is not inside your GOPATH. Sorry, perhaps this was the issue reported. Sorry, what I think you're trying to do isn't supported, the go tool will try to resolve each package relative to what it can find inside GOPATH and will build your code against the copy inside GOPATH. |
All dependencies are within my GOPATH.
Notice that the dependency ( |
Your code doesn't build with a clean checkout
|
Quick test, have you used symlinks inside your GOPATH? |
I have not used any symlinks. |
@davecheney what version of golang? I want to reproduce your output here locally. |
The repo you provided doesn't build or test cleanly.
Are you sure you're working with the right copy of your source? |
just did a clean checkout on master and getting the same error.
|
ok just did a full build on a clean vm.
|
This looks like a local environmental problem. Can this issue be closed?
…On Wed, 11 Jan 2017, 16:26 Jason McFarland ***@***.***> wrote:
ok just did a full build on a clean vm.
go get github.com/carbonblack/cb-event-forwarder
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
go generate ./...
go get ./...
go test
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18606 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA1oakZe7SjIEkOpx2-e76IoJS7u4ks5rRGgDgaJpZM4LgMPv>
.
|
I can reproduce on Linux and Mac. The Linux VM was clean. Any ideas on what could the problem possibly be? I have updated build instructions. |
My best guess is GOPATH is not set correctly, or your source is not within GOPATH. |
Current Directory:
Here is the compile with the pkg directory missing as well on linux amd64:
Here is go env:
go version:
|
I just tested golang version 1.6.4 on linux and everything works fine. So there might be some regression in 1.7 that is causing 'go test' to not see these dependencies. Here is the go version that worked for me. $ go version
This is probably why this issue popped up for us, since my colleague and I both recently upgraded to 1.7.4 |
That error is coming from cmd/compile, not the go tool. What's
print ? If you |
What does
print ? |
|
sorry
|
|
ls -al $GOPATH/pkg/linux_amd64/github.com/streadway/ |
so i did a |
|
so does this mean prior to doing go test, we need to delete all the packages? Or are we doing something wrong that has changed in 1.7? |
Ok, here's my best guess for what happed. Recommendation: use |
so always do a |
It kinda depends anywhere you'd use go build, use go install
If you're buiding in ci, it doesn't matter 'cos your work will be throwing
away at the end of the build, but on your local machine it'll reduce the
time to build and test.
…On Wed, Jan 11, 2017 at 5:00 PM, Jason McFarland ***@***.***> wrote:
so always do a go install prior to doing go test?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18606 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA2wLCUTKj8fat5QhAilG6u18FZUJks5rRHARgaJpZM4LgMPv>
.
|
When I use |
Can you please post the full output of running that command with the `-x`
flag.
…On Wed, Jan 11, 2017 at 5:25 PM, Jason McFarland ***@***.***> wrote:
When I use go install on that amqp package I still get the same error.
Basically I don't think the go tool is finding my pkg directory at all.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18606 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA-2fOjIfmo4m8t0G3AMWLGPe6hIPks5rRHXggaJpZM4LgMPv>
.
|
which command do you want? go install on the amqp package or a go test with the error? |
Here is the full
Notice how the pkg directory is missing in the compile flags |
Want to make sure I'm not doing anything wrong, but here is our full build instructions that I perform prior to running
|
Yup, something is wrong with your environment. |
Try deleting this line |
I'm at a loss since everything compiles and tests fine with 1.6.4. In the morning I'll try your suggestion. Thank you for your time and I'll report back with updates. |
One thing, switching back and forth between go versions is known to cause
problems with stale .a files.
Going forward works fine, but going backwards will confuse the compiler
about which .a files are stale.
Always delete your GOPATH/pkg directory when downgrading go.
…On Wed, 11 Jan 2017, 17:40 Jason McFarland ***@***.***> wrote:
I'm at a loss since everything compiles and tests fine with 1.6.4. In the
morning I'll try your suggestion. Thank you for your time and I'll report
back with updates.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18606 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA9cf95uc6lQ855oxCvfm5mmY7tM8ks5rRHk_gaJpZM4LgMPv>
.
|
Yea I made sure I started fresh. |
same error after deleting line 4 in leef_encoder_test.go:
|
Also going to add that |
With the tip, I experience the following. After I fixed the the local import, go test succeeded. Is there a possible for you to try it with Go 1.8 beta?
|
Use the following commands to download and use the 1.8 beta:
I believe this is a build issue with an old installed library, wondering if 1.8 handles it already. |
go 1.8 beta2 seems to have fixed my external dependency issue that was present in 1.7.4. This issue can be marked as closed as it has apparently been fixed in 1.8.
|
Thanks all for your time |
No, please report if you see any weird behavior. |
Description
When running 'go test' from a path that conforms to normal golang directory structure (
/Users/builduser/Projects/golang/src/github.com/carbonblack/cb-event-forwarder
), build dependencies aren't getting resolved.I am able to successfully run 'go test' from a directory within my $GOPATH as long as it isn't within the src directory (
/Users/builduser/Projects/golang/cb-event-forwarder
).When running 'go test -x -v' from the conformant (
/Users/builduser/Projects/golang/src/github.com/carbonblack/cb-event-forwarder
) directory the pkg dependency directory is not set when attempting to compile:Notice the
-I "" -pack
. I can only deduce this is the issue when comparing to running 'go test' from a directory path (/Users/builduser/Projects/golang/cb-event-forwarder):TLDR 'go test' works when within $GOPATH as long as it isn't within the src directory, otherwise it can't find dependencies. I am one of the maintainers of the golang code in question. Thank you for your time.
What version of Go are you using (
go version
)?go version go1.7.4 darwin/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: