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

Macro errors while using podman-api crate in Bazel with rules_rust #156

Open
all2jeff opened this issue May 1, 2023 · 2 comments
Open
Labels
C-bug Category: issue or a bug

Comments

@all2jeff
Copy link

all2jeff commented May 1, 2023

  • Crate version: 0.10.0
  • OS: Linux
  • Output of running podman version on the command line: N/A

I've been trying to use the podman-api crate in a Bazel workspace by using rules_rust but lots of building errors occurred by just importing it. I have created a repo to recreate the problem in a vscode dev container.

The errors seem to be related to how variables are been captured for formatting within macros like impl_opts_builder and impl_opts_required_builder.
For example:

error: there is no argument named `params`
  --> external/crate_index__podman-api-0.10.0/src/opts/containers.rs:11:1
   |
11 | / impl_opts_builder!(url =>
12 | |     /// Adjust the list of returned containers with this options.
13 | |     ContainerList
14 | | );
   | |_^
   |
   = note: did you intend to capture a variable `params` from the surrounding scope?
   = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro
   = note: this error originates in the macro `$crate::impl_url_serialize` which comes from the expansion of the macro `impl_opts_builder` (in Nightly builds, run with -Z macro-backtrace for more info)
error: there is no argument named `params`
  --> external/crate_index__podman-api-0.10.0/src/opts/images.rs:11:1
   |
11 | / impl_opts_required_builder!(url =>
12 | |     /// Adjust how an image is built.
13 | |     ImageBuild,
14 | |     ///
...  |
17 | |     path => "path"
18 | | );
   | |_^
   |
   = note: did you intend to capture a variable `params` from the surrounding scope?
   = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro
   = note: this error originates in the macro `$crate::impl_url_serialize` which comes from the expansion of the macro `impl_opts_required_builder` (in Nightly builds, run with -Z macro-backtrace for more info)

Do you guys happen to know anything about what is going wrong here?

@all2jeff all2jeff added the C-bug Category: issue or a bug label May 1, 2023
@vv9k
Copy link
Owner

vv9k commented May 29, 2023

Sorry for late response, I had very little time recently.

I've looked into the issue but I'm unsure how to test if the fix works as I'm not entirely sure how to specify the dependency by git commit (it's seems to be impossible with bazel). I'm not really accustomed with bazel so the test will probably have to wait until next version of podman-api is released.

EDIT:
The changes were made in containers-api crate here

@all2jeff
Copy link
Author

all2jeff commented Jul 23, 2023

Thank you for your fix @vv9k!
As you said, there seems to be no direct way to overwrite the dependency of a dependency from bazel rules.
However, I managed to find a way to do it. And I'm happy to see that your fix worked. :)

Meanwhile, I'm looking forward to the next release for both crates 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: issue or a bug
Projects
None yet
Development

No branches or pull requests

2 participants