Skip to content

Fix issues on bazeldnf and xattr rule invocations #135

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

Merged
merged 2 commits into from
May 30, 2025
Merged

Fix issues on bazeldnf and xattr rule invocations #135

merged 2 commits into from
May 30, 2025

Conversation

rmohr
Copy link
Owner

@rmohr rmohr commented May 30, 2025

First, if bazeldnf is invoked via bazel itself, transitive dependencies are treated as iterables, which is long deprecated and which can fail on newer versions with:

Error in extend: type 'depset' is not iterable

Second, the xattr rule was not properly constructing the arguments list which seems to only now be visible:

		args += ["--capabilities", ",".join(capabilities)]
Error in join: expected string for sequence element 0, got 'list'

rmohr added 2 commits May 29, 2025 16:56
Fix errors like

```
$ bazel run  //rpm:ldd_x86_64
DEBUG: /usr/local/google/home/rmohr/.cache/bazel/_bazel_rmohr/4c1501bf8a3fa32b59ed554fc2f4f732/external/bazeldnf/def.bzl:10:10: import this method from @bazeldnf//bazeldnf:defs.bzl
ERROR: /usr/local/google/home/rmohr/gerrit/kubevirt/rpm/BUILD.bazel:21:9: in _bazeldnf rule //rpm:ldd_x86_64:
Traceback (most recent call last):
	File "/usr/local/google/home/rmohr/.cache/bazel/_bazel_rmohr/4c1501bf8a3fa32b59ed554fc2f4f732/external/bazeldnf/internal/bazeldnf.bzl", line 18, column 39, in _bazeldnf_impl
		transitive_dependencies.extend(ctx.attr.tar.files)
Error in extend: type 'depset' is not iterable
```

Signed-off-by: Roman Mohr <rmohr@google.com>
By accident arrays of capabilities were added insteads of strings.

Fixes errors like

```
ERROR: /usr/local/google/home/rmohr/gerrit/kubevirt/cmd/virt-launcher/BUILD.bazel:73:7: in _xattrs rule //cmd/virt-launcher:blub:
Traceback (most recent call last):
	File "/usr/local/google/home/rmohr/.cache/bazel/_bazel_rmohr/4c1501bf8a3fa32b59ed554fc2f4f732/external/bazeldnf/internal/xattrs.bzl", line 28, column 44, in _xattrs_impl
		args += ["--capabilities", ",".join(capabilities)]
Error in join: expected string for sequence element 0, got 'list'
```

Signed-off-by: Roman Mohr <rmohr@google.com>
@rmohr rmohr requested a review from manuelnaranjo May 30, 2025 00:04
Copy link

⚠️ Optional job e2e-bzlmod-toolchain-circular-dependencies failed ⚠️

  • exit status: 1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use ctx.actions.args instead, it knows how to expand depart when used with joinall and others, but maybe that can wait another PR and not as part of this one

Copy link
Collaborator

@manuelnaranjo manuelnaranjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to replace with ctx.actions.args

@rmohr
Copy link
Owner Author

rmohr commented May 30, 2025

Feel free to replace with ctx.actions.args

Do you have an example pointer? I can do a follow-up.

@rmohr rmohr merged commit f4c6e35 into main May 30, 2025
14 checks passed
@manuelnaranjo
Copy link
Collaborator

https://www.stevenengelhardt.com/2020/11/12/practical-bazel-use-ctx.actions.args-to-form-arguments-lists/ there's and add_all_joined that takes a separator as argument, it has slight performance improvements as depsets are only expanded on the build phase and not at analysis

rmohr added a commit to rmohr/kubevirt that referenced this pull request Jun 4, 2025
…patibility

The new version has a few fixes which are potentially hit on newer bazel
versions due to plugin code changes and is also module ready in
principle.

Most notably it brings in rmohr/bazeldnf#135.
rmohr added a commit to rmohr/kubevirt that referenced this pull request Jun 4, 2025
…patibility

The new version has a few fixes which are potentially hit on newer bazel
versions due to plugin code changes and is also module ready in
principle.

Most notably it brings in rmohr/bazeldnf#135.

Signed-off-by: Roman Mohr <rmohr@google.com>
brianmcarey pushed a commit to brianmcarey/kubevirt that referenced this pull request Jun 5, 2025
…patibility

The new version has a few fixes which are potentially hit on newer bazel
versions due to plugin code changes and is also module ready in
principle.

Most notably it brings in rmohr/bazeldnf#135.

Signed-off-by: Roman Mohr <rmohr@google.com>
rmohr added a commit to rmohr/kubevirt that referenced this pull request Jun 9, 2025
…patibility

The new version has a few fixes which are potentially hit on newer bazel
versions due to plugin code changes and is also module ready in
principle.

Most notably it brings in rmohr/bazeldnf#135.

Signed-off-by: Roman Mohr <rmohr@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants