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

Using wrong golang/x/net version #1021

Closed
franciscocpg opened this issue Mar 30, 2021 · 2 comments
Closed

Using wrong golang/x/net version #1021

franciscocpg opened this issue Mar 30, 2021 · 2 comments
Labels

Comments

@franciscocpg
Copy link

What version of gazelle are you using?

v0.23.0

What version of rules_go are you using?

v0.27.0

What version of Bazel are you using?

Build label: 3.7.2
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Dec 22 11:00:37 2020 (1608634837)
Build timestamp: 1608634837
Build timestamp as int: 1608634837

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Linux x86_64

What did you do?

When using v0.23.0 with k8s.io/client-go I see the following error:

external/io_k8s_apimachinery/pkg/util/net/http.go:174:13: undefined: http2.ConfigureTransports
compilepkg: error running subcommand external/go_sdk/pkg/tool/linux_amd64/compile: exit status 2

It looks like, for some reason, it's using the wrong golang/x/net when building, even I'm forcing the version like this:

go_repository(
    name = "org_golang_x_net",
    importpath = "golang.org/x/net",
    sum = "h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=",
    version = "v0.0.0-20201110031124-69a78807bb2b",
)

My guess is something related to this commit?
5d15f00#diff-5493ff8e9397811510e780de47c57abb70137f1afe85d1519130dc3679d60ce5R43

My workaround, for now, is using v0.22.3 but I started to use embed in my projects and I want to use it with gazelle/rules_go.

What did you expect to see?

Compile successfully.

What did you see instead?

Compile failing.

@franciscocpg franciscocpg changed the title golang/x/net version error Using wrong golang/x/net version Mar 30, 2021
@jayconrod
Copy link
Contributor

The line you pointed to only applies to Gazelle running in its own repository, so I don't think that's the issue.

This looks like a problem with dependencies in WORKSPACE though. Could you confirm there is exactly one declaration of org_golang_x_net in WORKSPACE, including in any functions called from WORKSPACE? If there are multiple declarations, for example, in functions, Bazel has some fairly complicated logic about whether the later definition "wins" or not. Organizing Bazel WORKSPACE files might be helpful if this is the case.

If that's not it, please post a minimal reproducible example.

@franciscocpg
Copy link
Author

franciscocpg commented Mar 30, 2021

Hi @jayconrod.

Thank you for your answer.

After reading your answer and article, I moved the declaration of org_golang_x_net near to the top of my WORKSPACE file and it worked.

But until v0.22.3 this change wasn't needed. I don't know why.

I searched in my repo and there are no other declarations of org_golang_x_net.

Here are the changes I've made.

diff --git a/WORKSPACE b/WORKSPACE
index 5939b74..09dab36 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -33,10 +33,10 @@ http_archive(
 
 http_archive(
     name = "bazel_gazelle",
-    sha256 = "222e49f034ca7a1d1231422cdb67066b885819885c356673cb1f72f748a3c9d4",
+    sha256 = "62ca106be173579c0a167deb23358fdfe71ffa1e4cfdddf5582af26520f1c66f",
     urls = [
-        "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz",
-        "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz",
+        "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz",
+        "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz",
     ],
 )
 
@@ -50,6 +50,13 @@ load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
 
 gazelle_dependencies()
 
+go_repository(
+    name = "org_golang_x_net",
+    importpath = "golang.org/x/net",
+    sum = "h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=",
+    version = "v0.0.0-20201110031124-69a78807bb2b",
+)
+
 go_repository(
     name = "com_github_azure_go_autorest_autorest",
     importpath = "github.com/Azure/go-autorest/autorest",
@@ -1999,13 +2006,6 @@ go_repository(
     version = "v0.0.0-20210220033148-5ea612d1eb83",
 )
 
-go_repository(
-    name = "org_golang_x_net",
-    importpath = "golang.org/x/net",
-    sum = "h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=",
-    version = "v0.0.0-20201110031124-69a78807bb2b",
-)
-
 go_repository(
     name = "org_golang_x_sync",
     importpath = "golang.org/x/sync",

Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants