-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: cannot Resolve K8s Package from Dependency #27457
Comments
@swtch1 this situation comes about because of breaking changes in the There is a way to "fix" your case however, and that is to bootstrap your dependencies from the # use a clean GOPATH for testing
export GOPATH=$(mktemp -d)
cd $(mktemp -d)
mkdir hello
cd hello
go mod init example.com/hello
cat <<EOD > main.go
package main
import (
"github.com/prometheus/prometheus/config"
)
func main() {}
var c config.Config
EOD
# create a temporary directory for a prometheus clone
pd=$(mktemp -d)
git clone https://github.com/prometheus/prometheus/ $pd
pushd $pd
go mod init
popd
# now back to our example
go mod edit -require=github.com/prometheus/prometheus@latest -replace=github.com/prometheus/prometheus=$pd
go build main.go succeeds. cc @rsc @bcmills. Perhaps when resolving EDIT: to merge the two |
In an earlier draft of module support we did that to synthesize a converted I suppose we could add the dependencies implied by |
Thanks for the background @bcmills. @swtch1 sounds like this is working as intended. Hopefully my explanation and workaround in #27457 (comment) are clear. Indeed that workaround (or a variation on it) could be absorbed into a special That said, this does seem like a fairly uncommon case (I'll wait to be disproved on that statement 😄) |
Hey @myitcv. Thank you very much for providing the script here, but this does not succeed for me. The first error I get is: Then after adding
I have tried running this script on git bash on Windows, Windows subsystem for linux (Ubuntu) and CentOS, all with the same result. All are running the latest Go build. I do see this error in the middle of the scripted commands:
I am very appreciative of the work you've done but at this point I still have no way to build. Do you have any further tips? Am I supposed to be entering a specific version there instead of |
@swtch1 just to be clear, does a copy-paste of the commands in #27457 (comment) work for you? Please note I've just made a slight tweak to the comment to fix one of the commands apologies for that, so a page refresh might be required If not, please can you include the full output? I ask because those steps don't say anything about adding |
@myitcv your script modifications worked for me. I really can't thank you enough.. I haven't been able to build this project since I added those deps. This is seriously huge, thank you! Also not something I think I would have figured out on my own as I played with the replacements and other methods for hours. |
I'm a bit perplexed as to why you need a local clone and a I tried digging into it a bit, but ran into trouble because I had to clear my module cache (pre-1.11 weirdness) and then couldn't re-resolve |
Not quite sure what you mean @bcmills? Doing a |
I'll post more detail once I can get a trace of commands that work. 🙂 |
Ok, there is one outstanding bug here, but the rest seems to work fine without any The bug is that, for some reason, If I fix that with a Using the source file from the original report:
|
Ah I see what you mean now @bcmills
Indeed, but in its place you have to know to perform the various Or was this more a case of chasing down why the approach originally described in this issue didn't work? |
Yes. In general, if you have multiple pre-module dependencies you may need to use The number of such cases should drop as more repos get module definitions.
The fact that you suggested |
Absolutely.
👍 |
Having a similar issue as described here: https://groups.google.com/forum/#!topic/golang-nuts/BYV0IH_809Q. Thanks @myitcv for pointing me to this issue. The "fix" seems to be some of what @bcmills described. ApiMachinery wasn't the version I wanted even after a
|
I decided to look into the For your convenience, try:
That should at least rough in a consistent starting point for your own module. |
@bcmills thanks! |
What version of Go are you using (
go version
)?go version go1.11 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Windows 10 Enterprise x64
Reproduced with go1.11 on Windows Subsystem for Linux (Ubuntu) as well.
What did you do?
Tried to run go test/go build with code that uses methods from the prometheus monitoring project.
Reproduce with:
Ultimately related to issues I've opened before #26843 and dep issue 1976.
At this point I'm a bit perplexed as to how to deal with this.
What did you expect to see?
The standard behavior of a test or build.
What did you see instead?
$ go mod verify all modules verified $ go build main.go go: finding github.com/Azure/azure-sdk-for-go/arm/compute latest go: finding github.com/Azure/azure-sdk-for-go/arm/network latest go: finding github.com/Azure/azure-sdk-for-go/arm latest go: finding k8s.io/client-go/pkg/api latest go: finding k8s.io/client-go/pkg/apis/extensions/v1beta1 latest go: finding k8s.io/client-go/pkg latest go: finding k8s.io/client-go/pkg/apis/extensions latest go: finding k8s.io/client-go/pkg/apis latest build promtest: cannot find module for path github.com/Azure/azure-sdk-for-go/arm/compute
Fix azure-sdk-for-go issue by adding to go.mod:
require github.com/Azure/azure-sdk-for-go v5.0.0-beta.0.20161028183111-bd73d950fa44+incompatible // indirect
Oddly enough, k8s.io/client-go/pkg/api does not exist in the prometheus vendor directory and I cannot find it remapped in their vendor.json. Could k8s.io/client-go/pkg/api be using k8s.io/api?
The text was updated successfully, but these errors were encountered: