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

warning when upgrading from 0.50 -> 0.51 #4199

Closed
pdeva opened this issue Dec 19, 2024 · 6 comments · Fixed by bazel-contrib/bazel-gazelle#2003
Closed

warning when upgrading from 0.50 -> 0.51 #4199

pdeva opened this issue Dec 19, 2024 · 6 comments · Fixed by bazel-contrib/bazel-gazelle#2003

Comments

@pdeva
Copy link

pdeva commented Dec 19, 2024

What version of rules_go are you using?

0.51.0

What version of gazelle are you using?

0.40.0

What version of Bazel are you using?

7.4.1

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

yes

What operating system and processor architecture are you using?

linux
x64

Any other potentially useful information about your toolchain?

What did you do?

bazel_dep(name = "gazelle", version = "0.40.0", repo_name = "bazel_gazelle")
bazel_dep(name = "rules_go", version = "0.51.0", repo_name = "io_bazel_rules_go")

go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.22.1")

go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")

What did you expect to see?

no warning

What did you see instead?

DEBUG: /mnt/code/bazel/out/base/external/gazelle~/internal/bzlmod/go_deps.bzl:571:40: 

Mismatch between versions requested for module github.com/bazelbuild/rules_go
Bazel dependency version requested in MODULE.bazel: 0.51.0
Go module version requested in go.mod: 0.50.1
Please resolve this mismatch to prevent discrepancies between native Go and Bazel builds
@fmeum
Copy link
Member

fmeum commented Dec 19, 2024

What's the version for github.com/bazelbuild/rules_go in your go.mod file? Does the warning go away if you match the version of rules_go in your module file?

@pdeva
Copy link
Author

pdeva commented Dec 19, 2024

What's the version for github.com/bazelbuild/rules_go in your go.mod file? Does the warning go away if you match the version of rules_go in your module file?

there is no rules_go mentioned anywhere in my go.mod or even go.sum file..

@PingWriter
Copy link

PingWriter commented Dec 19, 2024

0.50.1 is the version of rules_go requested by gazelle 0.40.0 inside its go.mod file.

  • The warning disappears if this dependency is removed from the go.mod of gazelle.

  • There's no warning if you add rule_go 0.51.0 inside the go.mod of the root module.

  • (This warning appears when go_deps is declared with isolate = True even if a rules_go is declared inside the go.mod of the root module)

@pdeva
Copy link
Author

pdeva commented Dec 19, 2024

i am not running with isolate = True.

in fact i just now tried adding isolate=true and build --experimental_isolated_extension_usagesflag

go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps",isolate = True)
go_deps.from_file(go_mod = "//:go.mod")

still getting the same warning

@PingWriter
Copy link

No no, don't use isolate = True, it just was a way to reproduce the warning.

@fmeum
Copy link
Member

fmeum commented Jan 4, 2025

Could you check whether bazel-contrib/bazel-gazelle#2003 fixes this?

fmeum added a commit to bazel-contrib/bazel-gazelle that referenced this issue Jan 6, 2025
**What type of PR is this?**

Bug fix

**What package or component does this PR mostly affect?**

go_deps

**What does this PR do? Why is it needed?**

* Only show a warning for version mismatches between `go.mod` and
`bazel_dep` if the dep is either a direct dep or the Bazel module
version is lower. This avoids noisy warnings, in particular on gazelle
itself due to its `go.mod` dependency on `rules_go`.
* Don't suggest importing deps from isolated usages that are shared with
the non-isolated usage.

**Which issues(s) does this PR fix?**

Fixes bazel-contrib/rules_go#4199
Work towards #1990

**Other notes for review**
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

Successfully merging a pull request may close this issue.

3 participants