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

Buildozer: Cannot print pathof a local_path_override rule #1286

Open
nnobelis opened this issue Aug 15, 2024 · 5 comments
Open

Buildozer: Cannot print pathof a local_path_override rule #1286

nnobelis opened this issue Aug 15, 2024 · 5 comments

Comments

@nnobelis
Copy link

I have a MODULE.bazel file with a local_path_override:

local_path_override(
    module_name = "test_module",
    path = "./modules/test_module",
)

When I run buildozer 'print module_name path' //MODULE.bazel:%local_path_override to get the value of the two attributes, I get:
test_module /home/user/MODULE.bazel

This is wrong: the second part should be ./modules/test_module.
This is because path is a builtin special attribute referring to the absolute path to the BUILD file that contains the rules.

https://github.com/bazelbuild/buildtools/blob/main/buildozer/README.md#print-commands

Is this a bug or is there an alternate way of doing this ?

@fmeum
Copy link
Contributor

fmeum commented Aug 15, 2024

You can work around this by temporarily renaming the attribute:

buildozer 'rename path not_path' //MODULE.bazel:%local_path_override
buildozer 'print module_name not_path' //MODULE.bazel:%local_path_override
buildozer 'rename not_path path' //MODULE.bazel:%local_path_override

(using a command file would be more efficient)

@nnobelis
Copy link
Author

Thanks for the hint, much appreciated.
I'll keep it as a last choice solution but I would prefer something that does not modify the build file or run 3 commands..

@nnobelis
Copy link
Author

Since no alternative came up, I will use your solution @fmeum and close this ticket.

@laurentlb
Copy link
Contributor

I think this is a valid issue. I'd suggest to keep the issue open.

@nnobelis nnobelis reopened this Aug 19, 2024
@nnobelis
Copy link
Author

@laurentlb 👍

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

No branches or pull requests

3 participants