[Bug]: tools/migrate_to_bzlmod crashes
Closed this issue · 4 comments
What happened?
migrate_to_bzlmod failed to handle an exception? The resolved_deps.py generated by bazel sync contains a bad line I guess:
"_action_listener": <unknown object com.google.devtools.build.lib.packages.Attribute$LabelListLateBoundDefault>,
Version
Development (host) and target OS/architectures:
Output of bazel --version
:
Bazelisk version: v1.19.0
Build label: 6.3.2
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Aug 8 15:48:33 2023 (1691509713)
Build timestamp: 1691509713
Build timestamp as int: 1691509713
Version of relevant rules from the WORKSPACE
or MODULE.bazel
file:
Language(s) and/or frameworks involved:
golang, rules_oci, protobuf, ...
https://github.com/googlecloudrobotics/core/blob/main/WORKSPACE
How to reproduce
mkdir bug && cd bug
git clone https://github.com/googlecloudrobotics/core.git
git clone https://github.com/bazelbuild/bazel-central-registry.git
cd core
../bazel-central-registry/tools/migrate_to_bzlmod.py -t //...
INFO: Executing command: bazel --version
bazel 6.3.2
INFO: Detected original workspace name: cloud_robotics
INFO: Generating ./resolved_deps.py file
INFO: Executing command: bazel clean --expunge
INFO: Executing command: bazel build --nobuild --experimental_repository_resolved_file=resolved_deps.py //...
Traceback (most recent call last):
File "/usr/local/google/home/ensonic/robco_github/core/../bazel-central-registry/tools/migrate_to_bzlmod.py", line 571, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/google/home/ensonic/robco_github/core/../bazel-central-registry/tools/migrate_to_bzlmod.py", line 525, in main
resolved_deps = load_resolved_deps(args.target, args.sync, args.force)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/google/home/ensonic/robco_github/core/../bazel-central-registry/tools/migrate_to_bzlmod.py", line 477, in load_resolved_deps
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 936, in exec_module
File "<frozen importlib._bootstrap_external>", line 1074, in get_code
File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/local/google/home/ensonic/robco_github/core/./resolved_deps.py", line 5952
"_action_listener": <unknown object com.google.devtools.build.lib.packages.Attribute$LabelListLateBoundDefault>,
^
SyntaxError: invalid syntax
### Any other information?
_No response_
Just upgraded to bazel 6.5.0, same error.
I just deleted the 3 lines containing "unknown object ..." and with that it starts to do something.
The migrate_to_bzlmod script is pretty out-dated, I'm trying to find some time to update it.
We're changing the toolchain rules in googlecloudrobotics/core#422 that seems to also sidestep the issue, so no rush. Thanks for providing the tool in the fist place.