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

go_register_toolchains: version must be a string like "1.15.5" or "host" #2953

Closed
ensonic opened this issue Sep 15, 2021 · 9 comments
Closed

Comments

@ensonic
Copy link

ensonic commented Sep 15, 2021

What version of rules_go are you using?

Trying to upgrade from v0.24.14 to either v0.26.0 or newer

What version of gazelle are you using?

v0.21.1
(0.22,x & v0.23.0 fail due to gazelle#1076)

What version of Bazel are you using?

4.2.1

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

Yes.

What operating system and processor architecture are you using?

debian linux, x86

What did you do?

    _maybe(
         http_archive,
         name = "io_bazel_rules_go",
-        sha256 = "e0015762cdeb5a2a9c48f96fb079c6a98e001d44ec23ad4fa2ca27208c5be4fb",
+        sha256 = "8e968b5fcea1d2d64071872b12737bbb5514524ee5f0a4f54f5920266c261acb",
         urls = [
-            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.14/rules_go-v0.24.14.tar.gz",
-            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.14/rules_go-v0.24.14.tar.gz",
-        ],
+            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.28.0/rules_go-v0.28.0.zip",
+            "https://github.com/bazelbuild/rules_go/releases/download/v0.28.0/rules_go-v0.28.0.zip",
+    ],
     )

Now try to run gazelle (or build):

bazel run //:gazelle
ERROR: Traceback (most recent call last):
	File "/usr/local/google/home/ensonic/robco_gob/cloud-robotics/WORKSPACE", line 81, column 15, in <toplevel>
		container_deps()
	File "/usr/local/google/home/ensonic/.cache/bazel/_bazel_ensonic/556f802681b2087c6d9a6bcc3d0d954b/external/io_bazel_rules_docker/repositories/deps.bzl", line 32, column 12, in deps
		go_deps()
	File "/usr/local/google/home/ensonic/.cache/bazel/_bazel_ensonic/556f802681b2087c6d9a6bcc3d0d954b/external/io_bazel_rules_docker/repositories/go_repositories.bzl", line 34, column 27, in go_deps
		go_register_toolchains()
	File "/usr/local/google/home/ensonic/.cache/bazel/_bazel_ensonic/556f802681b2087c6d9a6bcc3d0d954b/external/io_bazel_rules_go/go/private/sdk.bzl", line 444, column 17, in go_register_toolchains
		fail('go_register_toolchains: version must be a string like "1.15.5" or "host"')
Error in fail: go_register_toolchains: version must be a string like "1.15.5" or "host"

There are 4 more like this. The error are in external build rules (e.g io_bazel_rules_docker (which is updated to the latest release 0.19.0).

What did you expect to see?

No error :)

What did you see instead?

Error in parts that I can't change. I guess this is due to ordering of things?

@steeve
Copy link
Contributor

steeve commented Sep 15, 2021

Yes, you need to specify the version now, as per the README:

go_register_toolchains(version = "1.17")

@ensonic
Copy link
Author

ensonic commented Sep 16, 2021

Of course and I did that, but apparently other rules call go_register_toolchains(() without the version.

@steeve
Copy link
Contributor

steeve commented Sep 16, 2021

Do you know which one? I can't find any go_register_toolchains() in rules_docker

@ensonic
Copy link
Author

ensonic commented Sep 16, 2021

@steeve
Copy link
Contributor

steeve commented Sep 16, 2021

There is a workaround, see bazelbuild/rules_docker#1700 and #2761

@ensonic
Copy link
Author

ensonic commented Sep 17, 2021

Thanks, changing that gets be another issue:

 bazel run //:gazelle
ERROR: Skipping '//:gazelle': error loading package '': in /usr/local/google/home/ensonic/.cache/bazel/_bazel_ensonic/556f802681b2087c6d9a6bcc3d0d954b/external/bazel_gazelle/def.bzl: in /usr/local/google/home/ensonic/.cache/bazel/_bazel_ensonic/556f802681b2087c6d9a6bcc3d0d954b/external/bazel_gazelle/internal/gazelle_binary.bzl: Label '@io_bazel_rules_go//go/private:rules/aspect.bzl' is invalid because '@io_bazel_rules_go//go/private/rules' is a subpackage; perhaps you meant to put the colon here: '@io_bazel_rules_go//go/private/rules:aspect.bzl'?

I think I am stuck in a cycle of workarounds :/

@steeve
Copy link
Contributor

steeve commented Sep 17, 2021

Did you match you bumping rules_go with bumping gazelle as well ?

@ensonic
Copy link
Author

ensonic commented Sep 17, 2021

If I bump both it seems to work, but all new gazelle versions suffer from:
bazelbuild/bazel-gazelle#1076
:/

Running gazelle with go works after adding directive for defaults (otherwise gazelle rewrites all BUILD files to name go_libs/test differently from the default). I still get build issues (but those can probably be fixed by updating more packages).

So if a new gazelle release fixes bazelbuild/bazel-gazelle#1076, we can probably move on. Again thanks for the help.

@ensonic
Copy link
Author

ensonic commented Sep 21, 2021

By moving the container rules to the end of the WORKSPACE file, we don't need the workaround.

@ensonic ensonic closed this as completed Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants