-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
--lockfile_mode
doesn't actually work in Bazel 6.2
#18455
Comments
Hi @aaronmondal, |
I believe in Bazel 6.2, the lock file flag should be |
Sorry, I missed this. Now I can reproduce similar issue with an invalid |
@meteorcloudy True, we can handle the crashing part. |
Indeed, @aaronmondal did you intentionally created a |
Ok I just retested this again (and sorry for the late reply).
Sorry that was a typo. It's indeed just
No, that lockfile is created automatically by Bazel. I'm getting this by adding git clone [email protected]:eomii/rules_ll
cd rules_ll/examples
nix develop
# And then add `--lockfile_mode=update` to `examples/.bazelrc` and run e.g. `bazel test cpp`. rules_ll is somewhat customized and uses RBE toolchains during local development. The # Don't inherit PATH and LD_LIBRARY_PATH.
build --incompatible_strict_action_env
# Forbid network access unless explicitly enabled.
build --sandbox_default_allow_network=false
# Use correct runfile locations.
build --nolegacy_external_runfiles
# Enable sandboxing for exclusive tests like GPU performance tests.
test --incompatible_exclusive_test_sandboxed
# Make sure rules_cc uses the correct transition mechanism.
build --incompatible_enable_cc_toolchain_resolution
# Propagate tags such as no-remote for precompilations to downstream actions.
common --incompatible_allow_tags_propagation
# Bzlmod configuration.
common --enable_bzlmod
common --lockfile_mode=update
common --registry=https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/
common --registry=https://raw.githubusercontent.com/eomii/bazel-eomii-registry/main/
# Make sure to use the correct java runtime.
build --java_runtime_version=rbe_jdk
build --tool_java_runtime_version=rbe_jdk
# Always act as if using remote execution.
build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build --define=EXECUTOR=remote
# Remote optimizations.
build --experimental_remote_cache_compression
build --experimental_remote_build_event_upload=minimal
build --remote_download_minimal
build --nolegacy_important_outputs
# Smaller profiling. Careful. Disabling this might explode remote cache usage.
build --slim_profile
build --experimental_profile_include_target_label
build --noexperimental_profile_include_primary_output
# Allow user-side customization.
try-import %workspace%/.bazelrc.user |
Hmm I thought that maybe the fact that we're using a |
@aaronmondal Yes, that shouldn't matter. I will take a close look and get back to you. |
@aaronmondal Hi, I tried the mentioned scenario (though I am getting an error running that target) but I got a correct lockfile generated: So, can you try to provide a minimal repro? preferably without installing nix (I tried but had some errors: "error: failed to configure synthetic.conf") |
@SalmaSamy Thanks a lot for looking into this! The rules_ll toolchains don't work without the nix environment. We wrap the entire Bazel executable twice to ensure full reproducibility beyond labels. The upside of this is that it lets you use remote execution toolchains locally (e.g. to share the same remote cache between locally running builds of different trusted users), but it won't work at all without the nix environment which contains all the pinned tools. We also only support linux environments, so these toolchains most likely won't work even if nix was set up. That shouldn't be related to this issue though. If the lockfile is generated correctly with your local toolchains it's probably related to some Java or glibc incompatibility. Since the lockfile is working even with the FYI the Java version that is used at the moment is I'm suspecting that this is related to Java version mismatch. Which java version is running on your system? I can try cycling through various Java versions to see whether the issue persists. I might be able to create a non-nix reproducer by using |
@aaronmondal Thanks for the context! But I'm not sure it's related the java version, since the lock file support in 6.2 only takes Bazel modules into account, but the JDK repos are not Bazel modules. |
@aaronmondal I see, I was running |
Add new exception for this function to handle any syntax errors or missing data within the lockfile Related: #18455 PiperOrigin-RevId: 538144339 Change-Id: I82160f3bff6598c26b3f99c824fe85ea86086c1f
Add new exception for this function to handle any syntax errors or missing data within the lockfile Related: #18455 PiperOrigin-RevId: 538144339 Change-Id: I82160f3bff6598c26b3f99c824fe85ea86086c1f
Add new exception for this function to handle any syntax errors or missing data within the lockfile Related: #18455 PiperOrigin-RevId: 538144339 Change-Id: I82160f3bff6598c26b3f99c824fe85ea86086c1f
* Update lockfile function exception Add new exception for this function to handle any syntax errors or missing data within the lockfile Related: #18455 PiperOrigin-RevId: 538144339 Change-Id: I82160f3bff6598c26b3f99c824fe85ea86086c1f * Update lockfile writing logic to be event triggered. The writing will only happen at the end of resolution in the after command function (at this point, the module and all needed module extensions are resolved). Which solves the problem of reading and writing into the lockfile multiple times in one invocation. PiperOrigin-RevId: 540552139 Change-Id: I4a78412a388bde2ff7949d119831318c40d49047 # Conflicts: # src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelDepGraphFunction.java # src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileFunction.java # src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileFunctionTest.java * Add module extension to lockfile PiperOrigin-RevId: 543445157 Change-Id: Ib32a2c9fdc22c5b228d78141fc9648b3ef5edf7d # Conflicts: # src/main/java/com/google/devtools/build/lib/bazel/bzlmod/GsonTypeAdapterUtil.java # src/main/java/com/google/devtools/build/lib/bazel/bzlmod/SingleExtensionEvalFunction.java * fixes * Fix tests * Enable lockfile by default and fix warning PiperOrigin-RevId: 545927412 Change-Id: I34e8531b8e396ccdfe0eecbee22cb68f76f969fc # Conflicts: # src/test/java/com/google/devtools/build/lib/analysis/RunfilesRepoMappingManifestTest.java # src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelDepGraphFunctionTest.java # src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionFunctionTest.java # src/test/java/com/google/devtools/build/lib/query2/testutil/SkyframeQueryHelper.java # src/test/java/com/google/devtools/build/lib/rules/starlarkdocextract/StarlarkDocExtractTest.java * Add lockfile documentation PiperOrigin-RevId: 546085523 Change-Id: If287e6e143f8858d185f83a1630275520db65e44 # Conflicts: # site/en/_book.yaml * Fix null event issue If a change "only" occurred in a module extension, then the value of ModuleResolutionEvent is null -the skyvalue is cached and the event was never sent- then "combineModuleExtensions" function would crash with null pointer exception while trying to get the old usages. In this case we can just re-add the old module extensions from the lockfile because if the module resolution is the same, this means the usage didn't change. PiperOrigin-RevId: 546821911 Change-Id: Ie685cbab654d1c41403aebd31ddad91033be1d56 * Fix tests * Update lockfile function exception Add new exception for this function to handle any syntax errors or missing data within the lockfile Related: #18455 PiperOrigin-RevId: 538144339 Change-Id: I82160f3bff6598c26b3f99c824fe85ea86086c1f * Update lockfile writing logic to be event triggered. The writing will only happen at the end of resolution in the after command function (at this point, the module and all needed module extensions are resolved). Which solves the problem of reading and writing into the lockfile multiple times in one invocation. PiperOrigin-RevId: 540552139 Change-Id: I4a78412a388bde2ff7949d119831318c40d49047 # Conflicts: # src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelDepGraphFunction.java # src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileFunction.java # src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileFunctionTest.java * Add module extension to lockfile PiperOrigin-RevId: 543445157 Change-Id: Ib32a2c9fdc22c5b228d78141fc9648b3ef5edf7d # Conflicts: # src/main/java/com/google/devtools/build/lib/bazel/bzlmod/GsonTypeAdapterUtil.java # src/main/java/com/google/devtools/build/lib/bazel/bzlmod/SingleExtensionEvalFunction.java * fixes * Fix tests * Enable lockfile by default and fix warning PiperOrigin-RevId: 545927412 Change-Id: I34e8531b8e396ccdfe0eecbee22cb68f76f969fc # Conflicts: # src/test/java/com/google/devtools/build/lib/analysis/RunfilesRepoMappingManifestTest.java # src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelDepGraphFunctionTest.java # src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionFunctionTest.java # src/test/java/com/google/devtools/build/lib/query2/testutil/SkyframeQueryHelper.java # src/test/java/com/google/devtools/build/lib/rules/starlarkdocextract/StarlarkDocExtractTest.java * Add lockfile documentation PiperOrigin-RevId: 546085523 Change-Id: If287e6e143f8858d185f83a1630275520db65e44 # Conflicts: # site/en/_book.yaml * Fix null event issue If a change "only" occurred in a module extension, then the value of ModuleResolutionEvent is null -the skyvalue is cached and the event was never sent- then "combineModuleExtensions" function would crash with null pointer exception while trying to get the old usages. In this case we can just re-add the old module extensions from the lockfile because if the module resolution is the same, this means the usage didn't change. PiperOrigin-RevId: 546821911 Change-Id: Ie685cbab654d1c41403aebd31ddad91033be1d56 * Fix tests * Remove unrelated updates * reverse unrelated changes
Closing this as inactionable. |
I'm having the same exact issue with a very minimal example (repro.zip) that sets up a simple python binary. No custom Running:
Results in the creation of a MODULE.bazel.lock file that contains an empty JSON object:
The next attempt to run the bazel command above results in the following crash:
Bazel version: > bazel --version
bazel 6.3.2-homebrew macOS version: > sw_vers
ProductName: macOS
ProductVersion: 14.0
BuildVersion: 23A344 |
@Wyverald can we reopen? |
Description of the bug:
My guess is that there is some bugfix missing. Invoking a build with
--lockfile_mode=update
creates aMODULE.bazel.lock
file with the content{}
on the initial invocation. All subsequent invocations then crash with the following stacktrace:What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
build --lockfile_mode=update
(and--enable_bzlmod
) to.bazelrc
Which operating system are you running Bazel on?
Gentoo x86_64
What is the output of
bazel info release
?release 6.2.0- (@non-git)
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.Release from nixpkgs.
Have you found anything relevant by searching the web?
This might be relevant: 23518b8
The text was updated successfully, but these errors were encountered: