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

[Bug]: Unknown object using migration tool on rules_rust crate_universe #20453

Open
Dig-Doug opened this issue Dec 23, 2022 · 8 comments
Open
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@Dig-Doug
Copy link

What happened?

When trying to use the migration tool, I get an error:

INFO: Executing command: bazel --version
bazel 6.0.0
INFO: Detected original workspace name: examples
INFO: Found existing ./resolved_deps.py file, if it's out of date, please delete it and rerun the script.
Traceback (most recent call last):
  File "/tmp/bazel-central-registry/tools/migrate_to_bzlmod.py", line 510, in <module>
    sys.exit(main())
  File "/tmp/bazel-central-registry/tools/migrate_to_bzlmod.py", line 473, in main
    resolved_deps = load_resolved_deps(argv)
  File "/tmp/bazel-central-registry/tools/migrate_to_bzlmod.py", line 455, in load_resolved_deps
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 879, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1017, in get_code
  File "<frozen importlib._bootstrap_external>", line 947, in source_to_code
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/tmp/rules_rust/examples/crate_universe/./resolved_deps.py", line 255
    "_action_listener": <unknown object com.google.devtools.build.lib.packages.Attribute$LabelListLateBoundDefault>,
                        ^
SyntaxError: invalid syntax

Version

Development (host) and target OS/architectures:

Output of bazel --version:

bazel version
Bazelisk version: development
Build label: 6.0.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Dec 19 15:52:35 2022 (1671465155)
Build timestamp: 1671465155
Build timestamp as int: 1671465155

Version of relevant rules from the WORKSPACE or MODULE.bazel file:

Uses crate_universe to resolve rust dependencies.

Language(s) and/or frameworks involved:

rules_rust

How to reproduce

cd /tmp
git clone git@github.com:bazelbuild/rules_rust.git
git clone https://github.com/bazelbuild/bazel-central-registry.git
cd rules_rust/examples/crate_universe
mv WORKSPACE.bazel WORKSPACE
/tmp/bazel-central-registry/tools/migrate_to_bzlmod.py //...:all

Any other information?

grep "<unknown" -A 30 -B 10 -m 1 resolved_deps.py
               "generator": "@cargo_bazel_bootstrap//:cargo-bazel",
               "lockfile": "//cargo_aliases:cargo-bazel-lock.json",
               "manifests": [
                    "//cargo_aliases:Cargo.toml"
               ]
          },
          "repositories": [
               {
                    "rule_class": "@rules_rust//crate_universe/private:crates_repository.bzl%crates_repository",
                    "attributes": {
                         "_action_listener": <unknown object com.google.devtools.build.lib.packages.Attribute$LabelListLateBoundDefault>,
                         "_config_dependencies": [],
                         "_configure": False,
                         "_environ": [
                              "CARGO_BAZEL_GENERATOR_URL",
                              "CARGO_BAZEL_GENERATOR_SHA256",
                              "CARGO_BAZEL_REPIN",
                              "REPIN",
                              "CARGO_BAZEL_ISOLATED"
                         ],
                         "annotations": {
                              "names": [
                                   "[\"0.12.1-dev\",{\"additive_build_file\":null,\"additive_build_file_content\":null,\"build_script_data\":null,\"build_script_data_glob\":null,\"build_script_deps\":null,\"build_script_env\":null,\"build_script_proc_macro_deps\":null,\"build_script_rustc_env\":null,\"build_script_toolchains\":null,\"build_script_tools\":null,\"compile_data\":null,\"compile_data_glob\":null,\"crate_features\":null,\"data\":null,\"data_glob\":null,\"deps\":null,\"gen_build_script\":null,\"patch_args\":null,\"patch_tool\":null,\"patches\":null,\"proc_macro_deps\":null,\"rustc_env\":null,\"rustc_env_files\":null,\"rustc_flags\":null,\"shallow_since\":\"1646516410 -0700\"}]"
                              ]
                         },
                         "applicable_licenses": [],
                         "aspect_hints": [],
                         "cargo_config": None,
                         "cargo_lockfile": "//cargo_aliases:Cargo.Bazel.lock",
                         "compatible_with": [],
                         "deprecation": <unknown object com.google.devtools.build.lib.analysis.BaseRuleClasses$2>,
                         "expect_failure": "",
                         "features": [],
                         "generate_build_scripts": True,
                         "generator": "@cargo_bazel_bootstrap//:cargo-bazel",
                         "generator_function": "",
                         "generator_location": "",
                         "generator_name": "",
                         "generator_sha256s": {},
                         "generator_urls": {},
                         "isolated": True,
@meteorcloudy meteorcloudy self-assigned this Dec 28, 2022
@meteorcloudy
Copy link
Member

Oh, it looks like Bazel failed to serialize the"_action_listener" attribute of @rules_rust//crate_universe/private:crates_repository.bzl%crates_repository, it should be bug in Bazel, but to work around this, can you remove this line and retry?

Ideally, you should wait for bazelbuild/rules_rust#1528 so that rules_rust properly supports Bzlmod.

@mering
Copy link

mering commented Dec 6, 2023

I also stumbled over this. Commenting out the following three lines as follows allowed me to proceed:

        "repositories": [{
            "rule_class": (
                "@com_grail_bazel_toolchain//toolchain:rules.bzl%llvm"
            ),
            "attributes": {
                # "_action_listener": <unknown object com.google.devtools.build.lib.packages.Attribute$LabelListLateBoundDefault>,
                "_config_dependencies": [],
                "_configure": False,
                "_environ": [],
                "_llvm_release_name": "@com_grail_bazel_toolchain//toolchain/tools:llvm_release_name.py",
                "_os_version_arch": (
                    "@com_grail_bazel_toolchain//toolchain/tools:host_os_key.py"
                ),
                "alternative_llvm_sources": [],
                "applicable_licenses": [],
                "aspect_hints": [],
                "auth_patterns": {},
                "compatible_with": [],
                # "deprecation": <unknown object com.google.devtools.build.lib.analysis.BaseRuleClasses$2>,
                "distribution": (
                    "clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz"
                ),
                "expect_failure": "",
                "features": [],
                "generator_function": "intrinsic_sdks_deps_1",
                "generator_location": None,
                "generator_name": "llvm_toolchain_llvm",
                "llvm_mirror": "",
                "llvm_version": "14.0.0",
                "name": "llvm_toolchain_llvm",
                "netrc": "",
                "restricted_to": [],
                "sha256": {},
                "strip_prefix": {},
                "tags": [],
                # "testonly": <unknown object com.google.devtools.build.lib.analysis.BaseRuleClasses$1>,
                "transitive_configs": [],
                "urls": {},
                "visibility": [],
            },
            "output_tree_hash": "962310da2230832a5a9738560a53e76a660d3a9ec97f55ce331ee0b59ce3cc7a",
        }],

@meteorcloudy
Copy link
Member

Oh, this is probably an issue in Bazel, can you please file an issue to the Bazel repo?

/cc @Wyverald @SalmaSamy

@meteorcloudy meteorcloudy transferred this issue from bazelbuild/bazel-central-registry Dec 6, 2023
@meteorcloudy meteorcloudy added area-Bzlmod Bzlmod-specific PRs, issues, and feature requests type: bug team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. P2 We'll consider working on this in future. (Assignee optional) labels Dec 6, 2023
@meteorcloudy
Copy link
Member

Never mind, I transferred the issue to Bazel repo.

@meteorcloudy
Copy link
Member

meteorcloudy commented Dec 6, 2023

@SalmaSamy Oh sorry, I misunderstood, this is not from the lockfile, but from the generated file by --experimental_repository_resolved_file. But still, maybe it's worth fixing from Bazel side.

@Wyverald
Copy link
Member

Wyverald commented Dec 6, 2023

The part in question looks like a BUILD rule target instead of a repo rule, which would explain all the weirdness. The problem then is to figure out why we're trying to include this in the resolved workspace file at all...

@meteorcloudy meteorcloudy added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed P2 We'll consider working on this in future. (Assignee optional) labels Dec 7, 2023
@meteorcloudy
Copy link
Member

OK, maybe a P3...

Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

No branches or pull requests

5 participants