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

bazel_6: MODULE.bazel.lock file is empty #273500

Closed
avdv opened this issue Dec 11, 2023 · 2 comments · Fixed by #283480
Closed

bazel_6: MODULE.bazel.lock file is empty #273500

avdv opened this issue Dec 11, 2023 · 2 comments · Fixed by #283480
Labels
0.kind: bug Something is broken

Comments

@avdv
Copy link
Member

avdv commented Dec 11, 2023

Describe the bug

Using Bazel from nixpkgs in a project with bzlmod enabled, and --lockfile_mode=update the generated MODULE.bazel.lock file does only contain an empty JSON object.

Steps To Reproduce

Steps to reproduce the behavior:

  1. git clone https://github.com/bazelbuild/examples.git
  2. cd examples/bzlmod/01-depend_on_bazel_module
  3. rm .bazelversion
  4. nix run nixpkgs#bazel_6 -- mod deps --lockfile_mode=update
$ nix run nixpkgs#bazel_6 version
Build label: 6.4.0- (@non-git)
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jan 1 00:00:00 1980 (315532800)
Build timestamp: 315532800
Build timestamp as int: 315532800
$ ls -lh MODULE.bazel.lock
-rw-r--r-- 1 claudio users 3 Dec 11 09:02 MODULE.bazel.lock
$ head MODULE.bazel.lock
{}

Expected behavior

The generated lock file should be equivalent to the file generated by a vanilla Bazel distribution binary:

$ bazel version
Bazelisk version: v1.16.0
Starting local Bazel server and connecting to it...
Build label: 6.4.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Oct 19 17:07:43 2023 (1697735263)
Build timestamp: 1697735263
Build timestamp as int: 1697735263
$  bazel mod deps --lockfile_mode=update
<root> ([email protected])

 checking cached actions
$ ls -lh ls -lh MODULE.bazel.lock 
-rw-r--r-- 1 root root 75K Dec 11 08:07 MODULE.bazel.lock
$ head MODULE.bazel.lock
{
  "lockFileVersion": 3,
  "moduleFileHash": "47f831d13c88b71ebfb233245e6e8c208f8d2e09b51e780699178a31ccf165dd",
  "flags": {
    "cmdRegistries": [
      "https://bcr.bazel.build/"
    ],
    "cmdModuleOverrides": {},
    "allowedYankedVersions": [],
    "envVarAllowedYankedVersions": "",

Additional context

See also bazelbuild/bazel#19672 where the same problem was reported for Bazel from homebrew.

The formula from homebrew is here:
https://github.com/Homebrew/homebrew-core/blob/fda88ddb4c8ea04adcfa001c56a1b35aebd64e86/Formula/b/bazel.rb

Notify maintainers

@NixOS/bazel

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.1-zen1, NixOS, 23.11 (Tapir), 23.11.20231128.7c4c205`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos-21.11.336182.a25df4c2b79"`
 - nixpkgs: `/etc/nixpkgs`

Add a 👍 reaction to issues you find important.

@avdv
Copy link
Member Author

avdv commented Dec 12, 2023

Comparing the server.jar from an official bindist and the bazel_6 package, it is apparent that the package one is missing all the gson type adapter classes:

com/google/devtools/build/lib/bazel/bzlmod/AttributeValues_GsonTypeAdapter.class
com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileValue_GsonTypeAdapter.class
com/google/devtools/build/lib/bazel/bzlmod/BzlmodFlagsAndEnvVars_GsonTypeAdapter.class
com/google/devtools/build/lib/bazel/bzlmod/GsonTypeAdapterUtil_RootModuleFileEscapingLocation_GsonTypeAdapter.class
com/google/devtools/build/lib/bazel/bzlmod/InterimModule_GsonTypeAdapter.class
com/google/devtools/build/lib/bazel/bzlmod/LockFileModuleExtension_GsonTypeAdapter.class
com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionEvalFactors_GsonTypeAdapter.class
com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionMetadata_GsonTypeAdapter.class
com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionUsage_GsonTypeAdapter.class
com/google/devtools/build/lib/bazel/bzlmod/Module_GsonTypeAdapter.class
com/google/devtools/build/lib/bazel/bzlmod/RepoSpec_GsonTypeAdapter.class
com/google/devtools/build/lib/bazel/bzlmod/Tag_GsonTypeAdapter.class

@aaronmondal
Copy link
Contributor

bazelbuild/bazel#18455

avdv added a commit to avdv/nixpkgs that referenced this issue Dec 20, 2023
This works around an issue with bootstrapping bazel from scratch, see
bazelbuild/bazel#20501

Fixes NixOS#273500
@avdv avdv mentioned this issue Jan 24, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants