native.bazel_version not tracked as repo rule input
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 44/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- build-system
Research direction
Start by reproducing the supplied example: it shows that a repository rule reading native.bazel_version keeps the old value across a Bazel upgrade unless the rule is local. Trace how repository rules record inputs in the marker file and how those inputs trigger refetches; the issue names no source files or tests. Done when a change to the Bazel version causes the non-local repository to be refetched, without making every MODULE file edit refetch it.
Written by the indexing model from the issue text.
Description
Description of the bug:
A repo rule can read native.bazel_version, but Bazel does not record it as an input. After a Bazel upgrade, the repo is not refetched and keeps the old version. The only workaround is local = True. But local repos are also refetched after every MODULE file edit, so every package that loads from them is reloaded.
"Low level" rulesets use this workaround, for e.g.
bazel_features: https://github.com/bazel-contrib/bazel_features/issues/25rules_cc: https://github.com/bazelbuild/rules_cc/blame/0.2.29/cc/extensions.bzl#L191rules_java: https://github.com/bazelbuild/rules_java/blob/9.9.0/java/rules_java_deps.bzl#L113
and almost every workspace loads them -- so this has a pretty big impact on analysis time esp. when a full workspace reload is required on every MODULE file change.
Ideally, when a repo rule reads native.bazel_version, Bazel records the value in the marker file, and refetch the repo when it changes.
Which category does this issue belong to?
External Dependency
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Version is not tracked (Bazel 9.3.2 -> 9.3.3)
#!/usr/bin/env bash
set -euo pipefail
cd "$(mktemp -d)"
cat > MODULE.bazel <<'EOF'
v = use_repo_rule("//:v.bzl", "v")
v(name = "v")
v_local = use_repo_rule("//:v.bzl", "v_local")
v_local(name = "v_local")
EOF
cat > v.bzl <<'EOF'
def _impl(rctx):
rctx.file("BUILD", "")
rctx.file("version.bzl", "VERSION = '%s'" % native.bazel_version)
v = repository_rule(_impl)
v_local = repository_rule(_impl, local = True)
EOF
printf 'load("@v//:version.bzl", "VERSION")\nload("@v_local//:version.bzl", V = "VERSION")\n' > BUILD
for version in 9.3.2 9.3.3; do
echo "$version" > .bazelversion
bazel query //:all >/dev/null 2>&1
ext="$(bazel info output_base 2>/dev/null)/external"
echo "Bazel $version: @v says $(cut -d"'" -f2 "$ext/+v+v/version.bzl"), @v_local says $(cut -d"'" -f2 "$ext/+v_local+v_local/version.bzl")"
done
Output:
Bazel 9.3.2: @v says 9.3.2, @v_local says 9.3.2
Bazel 9.3.3: @v says 9.3.2, @v_local says 9.3.3
Which operating system are you running Bazel on?
Linux
What is the output of bazel info release?
release 9.3.3
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse HEAD ?
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
- Dominant language
- Java
- Stars
- 26.2k
- Forks
- 4.7k
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 125
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bazelbuild/bazel
-
team-Rules-Java type: bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
bazelbuild/bazel#33068 ·
Maintainers usually reply within 2 days
-
Remote repo contents cache rejects repos with a backslash in a file name on UnixPossibly taken A pull request linked to this issue is open or already merged. Openteam-Remote-Exec type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bazelbuild/bazel#32601 · 3 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bazelbuild/bazel#32132 ·
Maintainers usually reply within 2 days
-
team-Local-Exec type: documentation (cleanup)
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bazelbuild/bazel#31318 ·
Maintainers usually reply within 2 days
-
Docs: run/build.mdx describes a sandboxing warning removed in 2017 and a flag deleted in 9.0.0Possibly taken @lavishdev claimed this 70 days ago. Openhelp wanted P2 team-Documentation team-OSS type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
bazelbuild/bazel#31316 ·
Maintainers usually reply within 2 days
All issues in bazelbuild/bazel
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Lincoln-cn/JAiRouter#1473 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
exercism/java-analyzer#379 ·
-
area: ui bug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
tetsuji16/microProject#1893 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
liberation-data/fornax4j#325 ·
Maintainers usually reply within 1 day
-
[Bug]: FE and Kinesis extraction pipes render flow starting at the centre and scroll the source arm backwardsPossibly taken @chonkzillaofficial claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
BCCE-team/BuildCraft#85 ·