Skip to content

Bzlmod Dependency Issues #1184

@jarreds

Description

@jarreds

Describe the bug

I'm having a heck of time with cel.dev/expr, cel-go, and a new bzlmod version of our repo.

First off, the error I'm seeing:

ERROR: /private/var/tmp/_bazel_jward/63162deb35ba6b2f678241a64a1d59bb/external/gazelle++go_deps+com_github_google_cel_go/common/types/BUILD.bazel:8:11: no such package '@@[unknown repo 'dev_cel_expr' requested from @@gazelle++go_deps+com_github_google_cel_go]//': The repository '@@[unknown repo 'dev_cel_expr' requested from @@gazelle++go_deps+com_github_google_cel_go]' could not be resolved: No repository visible as '@dev_cel_expr' from repository '@@gazelle++go_deps+com_github_google_cel_go' and referenced by '@@gazelle++go_deps+com_github_google_cel_go//common/types:go_default_library'

It seems that Bazel itself has some dependency on cel.dev/expr via a bazel_dep on cel-spec. So what that means, if you an import "cel.dev/expr" in your code, Gazelle will actually place the dep in your BUILD.bazel as "@cel-spec//:go_default_library". Getting all the version to align to even get bzlmod happy is pretty tricky, but in that case I still can't get it building.

So the list of what I have:

  1. Using bzlmod in project with Bazel version 8.2.1
  2. Have a dep on cel.dev/expr in one of my own packages
  3. Also have a dep on cel-go in one of my own packages
  4. rules_go 0.54.1
  5. gazelle 0.43.0

The incantation I'm at that has caused the above error:

MODULE.bazel

bazel_dep(
    name = "cel-spec",
    version = "0.23.0",
)

go.mod

require (
	cel.dev/expr v0.23.0
	github.com/google/cel-go v0.24.1
)

Honestly, this isn't the incantation I even want, but it's the only one I found that could make bzlmod happy, and it still doesn't work. Ideally I could just pull in latest versions.

Here's some examples of the run-around:

Run `go get github.com/google/[email protected]`
$ bazel run @rules_go//go -- get github.com/google/[email protected]
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
bazel: Entering directory `/private/var/tmp/_bazel_jward/63162deb35ba6b2f678241a64a1d59bb/execroot/_main/'
Analyzing: target @@rules_go+//go:go (0 packages loaded, 0 targets configured)
Analyzing: target @@rules_go+//go:go (0 packages loaded, 0 targets configured)

Analyzing: target @@rules_go+//go:go (19 packages loaded, 10305 targets configured)

INFO: Analyzed target @@rules_go+//go:go (92 packages loaded, 17359 targets configured).
INFO: Found 1 target...
bazel: Leaving directory `/private/var/tmp/_bazel_jward/63162deb35ba6b2f678241a64a1d59bb/execroot/_main/'
Target @@rules_go+//go/tools/go_bin_runner:go_bin_runner up-to-date:
  .bazel/bin/external/rules_go+/go/tools/go_bin_runner/bin/go
INFO: Elapsed time: 1.404s, Critical Path: 0.01s
INFO: 1 process: 11 action cache hit, 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: .bazel/bin/external/rules_go+/go/tools/go_bin_runner/bin/go <args omitted>
go: upgraded cel.dev/expr v0.23.0 => v0.23.1
go: upgraded github.com/google/cel-go v0.24.1 => v0.25.0
rules_go: Running 'bazel mod tidy' since go.mod changed...
 no actions running
DEBUG: /private/var/tmp/_bazel_jward/63162deb35ba6b2f678241a64a1d59bb/external/rules_jvm_external+/private/lib/coordinates.bzl:76:18: Assuming com.google.code.gson:gson:jar:2.9.0 should be interpreted as com.google.code.gson:gson:2.9.0@jar
DEBUG: /private/var/tmp/_bazel_jward/63162deb35ba6b2f678241a64a1d59bb/external/rules_jvm_external+/private/lib/coordinates.bzl:76:18: Assuming info.picocli:picocli:jar:4.6.3 should be interpreted as info.picocli:picocli:4.6.3@jar
DEBUG: /private/var/tmp/_bazel_jward/63162deb35ba6b2f678241a64a1d59bb/external/gazelle+/internal/bzlmod/go_deps.bzl:607:40: 
Mismatch between versions requested for Go module cel.dev/expr:

  bazel_dep version (MODULE.bazel): 0.23.0 (as "cel-spec")
  Go module version (go.mod):       0.23.1
 
Either ensure that you have

  bazel_dep(module_name = "cel-spec", version = "0.23.1")

in your MODULE.bazel file or downgrade the Go module version via

  bazel run @rules_go//go -- get cel.dev/[email protected]
Remove `bazel_dep` on `cel-spec`
bazel_dep(
    name = "cel-spec",
    version = "0.23.0",
)
$ bazel mod tidy
 no actions running
DEBUG: /private/var/tmp/_bazel_jward/63162deb35ba6b2f678241a64a1d59bb/external/rules_jvm_external+/private/extensions/maven.bzl:351:18: The maven repository 'maven' has contributions from multiple bzlmod modules, and will be resolved together: ["core", "grpc-java"]
DEBUG: /private/var/tmp/_bazel_jward/63162deb35ba6b2f678241a64a1d59bb/external/rules_jvm_external+/private/lib/coordinates.bzl:76:18: Assuming com.google.code.gson:gson:jar:2.9.0 should be interpreted as com.google.code.gson:gson:2.9.0@jar
DEBUG: /private/var/tmp/_bazel_jward/63162deb35ba6b2f678241a64a1d59bb/external/rules_jvm_external+/private/lib/coordinates.bzl:76:18: Assuming info.picocli:picocli:jar:4.6.3 should be interpreted as info.picocli:picocli:4.6.3@jar
DEBUG: /private/var/tmp/_bazel_jward/63162deb35ba6b2f678241a64a1d59bb/external/gazelle+/internal/bzlmod/go_deps.bzl:607:40: 
Mismatch between versions requested for Go module cel.dev/expr:

  bazel_dep version (MODULE.bazel): 0.15.0 (as "cel-spec")
  Go module version (go.mod):       0.23.1
 
Either ensure that you have

  bazel_dep(module_name = "cel-spec", version = "0.23.1")

in your MODULE.bazel file or downgrade the Go module version via

  bazel run @rules_go//go -- get cel.dev/[email protected]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions