rules_docker icon indicating copy to clipboard operation
rules_docker copied to clipboard

Incompatilibity with https://github.com/rules-proto-grpc/rules_proto_grpc

Open pjachowi opened this issue 2 years ago • 3 comments

$ blaze version Bazelisk version: development Build label: 5.3.0 Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar Build time: Tue Aug 23 00:45:53 2022 (1661215553) Build timestamp: 1661215553 Build timestamp as int: 1661215553

🐞 bug report

Affected Rule

Using @com_github_grpc_grpc//bazel:grpc_extra_deps.bzl with docker rules causes go error

Is this a regression?

I don't know

Description

Using @com_github_grpc_grpc//bazel:grpc_extra_deps.bzl together with docker rules causes to error bad.go:2:43: expected 'package', found 'EOF'

🔬 Minimal Reproduction

In the testing/examples/WORKSPACE add grpc rules (describe here https://rules-proto-grpc.com/en/latest/#installation and here https://rules-proto-grpc.com/en/latest/lang/python.html#id4):

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_proto_grpc",
    sha256 = "bbe4db93499f5c9414926e46f9e35016999a4e9f6e3522482d3760dc61011070",
    strip_prefix = "rules_proto_grpc-4.2.0",
    urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/4.2.0.tar.gz"],
)

load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_toolchains", "rules_proto_grpc_repos")
rules_proto_grpc_toolchains()
rules_proto_grpc_repos()

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()

load("@rules_proto_grpc//python:repositories.bzl", rules_proto_grpc_python_repos = "python_repos")

rules_proto_grpc_python_repos()

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

grpc_deps()

load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

grpc_extra_deps()

load("@rules_python//python:pip.bzl", "pip_install")

pip_install(
    name = "rules_proto_grpc_py3_deps",
    python_interpreter = "python3",
    requirements = "@rules_proto_grpc//python:requirements.txt",
)

🔥 Exception or Error






$ blaze test //...:all --define=VERBOSE_LOGS=1 
INFO: Build option --define has changed, discarding analysis cache.
DEBUG: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/bazel_gazelle/internal/go_repository.bzl:209:18: org_golang_x_tools: gazelle: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/cmd/fiximports/testdata/src/old.com/bad/bad.go: error reading go file: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/cmd/fiximports/testdata/src/old.com/bad/bad.go:2:43: expected 'package', found 'EOF'
gazelle: found packages server (issue29198.go) and issue34182 (issue34182.go) in /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/internal/gccgoimporter/testdata
gazelle: found packages a (a.go) and b (b.go) in /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/internal/gcimporter/testdata
gazelle: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/loader/testdata/badpkgdecl.go: error reading go file: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
gazelle: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/extra/geez/help.go: error reading go file: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/extra/geez/help.go:1:16: expected ';', found '.'
gazelle: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/extra/v2/geez/help.go: error reading go file: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/extra/v2/geez/help.go:1:16: expected ';', found '.'
gazelle: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/extra/v2/me.go: error reading go file: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/extra/v2/me.go:1:16: expected ';', found '.'
gazelle: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/extra/yo.go: error reading go file: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/extra/yo.go:1:16: expected ';', found '.'
gazelle: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/tempmod/main.go: error reading go file: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/tempmod/main.go:1:16: expected ';', found '.'
gazelle: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/[email protected]/main.go: error reading go file: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/[email protected]/main.go:1:16: expected ';', found '.'
gazelle: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/[email protected]/main.go: error reading go file: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/packages/packagestest/testdata/groups/two/modules/example.com/[email protected]/main.go:1:16: expected ';', found '.'
gazelle: finding module path for import domain.name/importdecl: go: unrecognized import path "domain.name/importdecl": https fetch: Get "https://domain.name/importdecl?go-get=1": dial tcp: lookup domain.name: No address associated with hostname
gazelle: finding module path for import old.com/one: go: unrecognized import path "old.com/one": https fetch: Get "http://www.old.com/one?go-get=1": redirected from secure URL https://old.com/one?go-get=1 to insecure URL http://www.old.com/one?go-get=1
gazelle: finding module path for import titanic.biz/bar: go: unrecognized import path "titanic.biz/bar": reading https://titanic.biz/bar?go-get=1: 403 Forbidden
gazelle: finding module path for import titanic.biz/foo: go: unrecognized import path "titanic.biz/foo": reading https://titanic.biz/foo?go-get=1: 403 Forbidden
gazelle: finding module path for import fruit.io/pear: go: unrecognized import path "fruit.io/pear": https fetch: Get "https://fruit.io/pear?go-get=1": dial tcp: lookup fruit.io: Temporary failure in name resolution
gazelle: finding module path for import fruit.io/banana: go: unrecognized import path "fruit.io/banana": https fetch: Get "https://fruit.io/banana?go-get=1": dial tcp: lookup fruit.io: Temporary failure in name resolution
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import nosuchpkg: go: malformed module path "nosuchpkg": missing dot in first path element
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import nosuchpkg: go: malformed module path "nosuchpkg": missing dot in first path element
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import referrers: go: malformed module path "referrers": missing dot in first path element
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import lib: go: malformed module path "lib": missing dot in first path element
gazelle: finding module path for import a: go: malformed module path "a": missing dot in first path element
gazelle: finding module path for import b: go: malformed module path "b": missing dot in first path element
gazelle: finding module path for import b: go: malformed module path "b": missing dot in first path element
gazelle: finding module path for import a: go: malformed module path "a": missing dot in first path element
gazelle: finding module path for import a: go: malformed module path "a": missing dot in first path element
gazelle: finding module path for import a: go: malformed module path "a": missing dot in first path element
gazelle: finding module path for import b: go: malformed module path "b": missing dot in first path element
gazelle: finding module path for import testdata/groups/two/expect: go: malformed module path "testdata/groups/two/expect": missing dot in first path element
gazelle: finding module path for import golang.org/x/tools/internal/lsp/assign/internal/secret: go: downloading golang.org/x/tools v0.1.12
go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/assign/internal/secret
gazelle: finding module path for import nosuchpkg: go: malformed module path "nosuchpkg": missing dot in first path element
gazelle: finding module path for import golang.org/x/tools/internal/lsp/circular/double/one: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/circular/double/one
gazelle: finding module path for import golang.org/x/tools/internal/lsp/circular/double/b: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/circular/double/b
gazelle: finding module path for import golang.org/x/tools/internal/lsp/circular/triple/b: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/circular/triple/b
gazelle: finding module path for import golang.org/x/tools/internal/lsp/circular/triple/c: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/circular/triple/c
gazelle: finding module path for import golang.org/x/tools/internal/lsp/circular/triple/a: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/circular/triple/a
gazelle: finding module path for import golang.org/x/tools/internal/lsp/circular: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/circular
gazelle: finding module path for import golang.org/x/tools/internal/lsp/foo: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/foo
gazelle: finding module path for import golang.org/x/tools/internal/lsp/types: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/types
gazelle: finding module path for import golang.org/x/tools/internal/lsp/foo: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/foo
gazelle: finding module path for import golang.org/x/tools/internal/lsp/godef/a: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/godef/a
gazelle: finding module path for import golang.org/x/tools/internal/lsp/types: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/types
gazelle: finding module path for import golang.org/x/tools/internal/lsp/implementation/other: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/implementation/other
gazelle: finding module path for import golang.org/x/tools/internal/lsp/foo: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/foo
gazelle: finding module path for import example.com/extramodule/pkg: go: unrecognized import path "example.com/extramodule/pkg": reading https://example.com/extramodule/pkg?go-get=1: 404 Not Found
gazelle: finding module path for import golang.org/x/tools/internal/lsp/foo: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/foo
gazelle: finding module path for import golang.org/x/tools/internal/lsp/foo: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/foo
gazelle: finding module path for import golang.org/x/tools/internal/lsp/references/other: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/references/other
gazelle: finding module path for import golang.org/x/tools/internal/lsp/references: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/references
gazelle: finding module path for import golang.org/x/tools/internal/lsp/rename/crosspkg: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/rename/crosspkg
gazelle: finding module path for import golang.org/x/tools/internal/lsp/signature: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/signature
gazelle: finding module path for import golang.org/x/tools/internal/lsp/signature: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/signature
gazelle: finding module path for import golang.org/x/tools/internal/lsp/types: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/types
gazelle: finding module path for import golang.org/x/tools/internal/lsp/signature: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/signature
gazelle: finding module path for import golang.org/x/tools/internal/lsp/snippets: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/snippets
gazelle: finding module path for import golang.org/x/tools/internal/lsp/baz: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/baz
gazelle: finding module path for import golang.org/x/tools/internal/lsp/signature: go: module golang.org/x/tools@upgrade found (v0.1.12), but does not contain package golang.org/x/tools/internal/lsp/signature
ERROR: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/io_bazel_rules_go/go/tools/builders/BUILD.bazel:51:10: no such target '@org_golang_x_tools//go/analysis:go_tool_library': target 'go_tool_library' not declared in package 'go/analysis' defined by /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/analysis/BUILD.bazel and referenced by '@io_bazel_rules_go//go/tools/builders:nogo_srcs'
ERROR: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/io_bazel_rules_go/go/tools/builders/BUILD.bazel:51:10: no such target '@org_golang_x_tools//go/analysis/internal/facts:go_tool_library': target 'go_tool_library' not declared in package 'go/analysis/internal/facts' defined by /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/analysis/internal/facts/BUILD.bazel and referenced by '@io_bazel_rules_go//go/tools/builders:nogo_srcs'
ERROR: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/io_bazel_rules_go/go/tools/builders/BUILD.bazel:51:10: no such target '@org_golang_x_tools//go/gcexportdata:go_tool_library': target 'go_tool_library' not declared in package 'go/gcexportdata' defined by /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/gcexportdata/BUILD.bazel and referenced by '@io_bazel_rules_go//go/tools/builders:nogo_srcs'
ERROR: Analysis of target '//run_instruction_arbitrary:bazel_gcloud_bazel_test.image' failed; build aborted: 
INFO: Elapsed time: 0.638s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (25 packages loaded, 1655 targets configured)
FAILED: Build did NOT complete successfully (25 packages loaded, 1655 targets configured)


🌍 Your Environment

Operating System:

  
$ uname -a
Linux gvtx43-99 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

  

Output of bazel version:

  
$ blaze version
Bazelisk version: development
Build label: 5.3.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Aug 23 00:45:53 2022 (1661215553)
Build timestamp: 1661215553
Build timestamp as int: 1661215553

  

Rules_docker version:

master branch from the GitHub repo as of 2022-08-29

  
$ git log
commit 94a7ddbcdcf0b66442f491d7a28cdf7a3aa14339 (HEAD -> master, origin/master, origin/HEAD)
Author: Zev Goldstein 
Date:   Mon Feb 14 11:39:24 2022 -0500

    remove unused and redundant --stamp-info-file

commit 4c1eaabcb6f52500373cf550e11982463d37a7a4
Author: Christian Persson 
Date:   Sat Aug 20 08:36:30 2022 +0100

    README.md: rename `client.json` -> `config.json` in one place.
    
    I was unlucky to miss all the other references to `config.json` when I was
    setting up, so I named my file `client.json`, looking instead only at the label
    changed by this commit.
    
    When I later ran a `container_push` target it failed with "permission denied"
    issues. I read the shell script generated by `container_push` and saw that it
    passes an argument to give the path to the _directory_ of the config file,
    rather than the path to the file itself.
    
    That made me realize that I had probably given the file the wrong name; the
    Docker client didn't find a `config.json` file in that directory and ignored all
    other files.

commit a8aff4076f75c4dfb39bd768dd9870b5d263e70d
Author: Nicholas Skehin 
Date:   Tue Aug 2 16:11:02 2022 +0100

    Add java_layer target that allows filtering JVM dependencies (#2122)

commit 55ffa702c85c9e958b8f4b1802883f91b4160f95
Author: jonjohnsonjr 
Date:   Sun Jul 24 19:48:19 2022 -0700

    Set MaxIdleConnsPerHost for pushes (#2132)
    
    This should reduce "use of closed network connection" errors due to too
    many idle connections. Because we only expect to reach a couple hosts
    during pushes anyway, this should be safe.
    
    Currently, the value defaults to 2. This change sets it to half the
    total IdleConnsPerHost, which defaults to 100.
    
    New value is 100 / 2 = 50.


  

Anything else relevant?

pjachowi avatar Aug 29 '22 08:08 pjachowi

Saw this when looking for another rules_docker issue, so figured I'd stop by. I saw this error or very similar when working on 4.2.0 and I believe it was an issue with recent Gazelle versions (I'd have to go check git log and CI log to find the failed build to be sure). Try moving the rules_proto_grpc loading in your WORKSPACE above rules_docker and see if you get the same error. If so, you may need to pin a specific gazelle version if there is a conflict.

aaliddell avatar Sep 01 '22 16:09 aaliddell

Neither works. grpc_extra_deps above rules_docker yields the error

DEBUG: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/bazel_gazelle/internal/go_repository.bzl:209:18: org_golang_x_tools: gazelle: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/cmd/fiximports/testdata/src/old.com/bad/bad.go: error reading go file: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/cmd/fiximports/testdata/src/old.com/bad/bad.go:2:43: expected 'package', found 'EOF'
gazelle: found packages nointerface (nointerface.go) and aliases (aliases.go) in /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/internal/gccgoimporter/testdata
gazelle: found packages a (a.go) and b (b.go) in /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/internal/gcimporter/testdata
gazelle: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/loader/testdata/badpkgdecl.go: error reading go file: /home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/org_golang_x_tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'

while grpc_extra_deps below rules_docker

ERROR: Traceback (most recent call last):
	File "/home/pjachowi/code/rules_docker/testing/examples/WORKSPACE", line 130, column 16, in <toplevel>
		grpc_extra_deps()
	File "/home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl", line 56, column 27, in grpc_extra_deps
		go_register_toolchains(version = "1.18")
	File "/home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/io_bazel_rules_go/go/private/sdk.bzl", line 241, column 5, in go_register_toolchains
		def go_register_toolchains(go_version = None, nogo = None):
Error: go_register_toolchains() got unexpected keyword argument: version (did you mean 'go_version'?)
ERROR: error loading package 'external': Package 'external' contains errors
INFO: Elapsed time: 6.347s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)

pjachowi avatar Sep 04 '22 06:09 pjachowi

I also tried to pin gazelle as the first rule

http_archive(
    name = "io_bazel_rules_go",
    sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
        "https://github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
    ],
)

http_archive(
    name = "bazel_gazelle",
    sha256 = "5982e5463f171da99e3bdaeff8c0f48283a7a5f396ec5282910b9e8a49c0dd7e",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
        "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
    ],
)


load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

############################################################
# Define your own dependencies here using go_repository.
# Else, dependencies declared by rules_go/gazelle will be used.
# The first declaration of an external repository "wins".
############################################################

go_rules_dependencies()

go_register_toolchains(version = "1.18.3")

gazelle_dependencies()

But it doesn't work either.

ERROR: Traceback (most recent call last):
	File "/home/pjachowi/code/rules_docker/testing/examples/WORKSPACE", line 83, column 16, in <toplevel>
		grpc_extra_deps()
	File "/home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl", line 56, column 27, in grpc_extra_deps
		go_register_toolchains(version = "1.18")
	File "/home/pjachowi/.cache/bazel/_bazel_pjachowi/5e134da5bf9b530e653d23b3eb9634dc/external/io_bazel_rules_go/go/private/sdk.bzl", line 462, column 13, in go_register_toolchains
		fail("go_register_toolchains: version set after go sdk rule declared ({})".format(", ".join([r["name"] for r in sdk_rules])))
Error in fail: go_register_toolchains: version set after go sdk rule declared (go_sdk)
ERROR: error loading package '': Encountered error while reading extension file 'repositories/repositories.bzl': no such package '@io_bazel_rules_docker//repositories': error loading package 'external': Could not load //external package
INFO: Elapsed time: 1.649s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)

pjachowi avatar Sep 04 '22 06:09 pjachowi

Did you find a solution to this problem? I'm encoutering the same issue in a WORKSPACE that uses https://github.com/grpc/grpc.

Enzzer avatar Dec 27 '22 10:12 Enzzer

I found a workaround consisting of putting in my WORKSPACE file explicite declaration of rules_go prior to rules_proto_grpc a the very beginning of the file

# File WORKSPACE begin here.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")

http_archive(
    name = "io_bazel_rules_go",
    sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
        "https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
    ],
)

http_archive(
    name = "rules_proto_grpc",
    sha256 = "bbe4db93499f5c9414926e46f9e35016999a4e9f6e3522482d3760dc61011070",
    strip_prefix = "rules_proto_grpc-4.2.0",
    urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/4.2.0.tar.gz"],
)

# Rest of the rules here.

I don't recommend it (it declares rulels_go out of nowhere because I don't use it in my project explicitely and must do it in particular order), but this is the only working solution I know.

pjachowi avatar Dec 27 '22 20:12 pjachowi

This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!

github-actions[bot] avatar Jun 26 '23 02:06 github-actions[bot]

This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"

github-actions[bot] avatar Jul 27 '23 02:07 github-actions[bot]