fmeum / buildozer

Pinned, prebuilt versions of buildozer for Bazel projects
MIT License
4 stars 0 forks source link

[FR] Support the usage of Buildozer present on host #16

Open albertocavalcante opened 3 months ago

albertocavalcante commented 3 months ago

Hey @fmeum,

I'm running into some issues with bazel mod tidy on Windows in a proxied environment that blocks *.exe downloads. Specifically, the problem arises when it runs: https://github.com/fmeum/buildozer/blob/main/private/buildozer_binary.bzl#L38.

I can install buildozer using:

go install github.com/bazelbuild/buildtools/buildozer@latest

So, I already have buildozer on my host PATH.

I'd like to ask for a way to use the buildozer that's already present on the host. This could be similar to how rules_go allows the use of a host toolchain, despite of its issues (https://github.com/enola-dev/enola/issues/713). I believe this is where they handle it: https://github.com/bazelbuild/rules_go/blob/v0.48.1/go/private/sdk.bzl#L491.

I initially thought about raising this as a feature request for Bazel itself, but I think implementing it directly in this rule set would be more beneficial.

EDIT: I'm working on getting it available in an internal mirror and add it to bazel_downloader.cfg as a potential fix for my current use case.

Still, is this something you'd be open to get implemented? Or think it's feasible?

Potential Workaround

I also think there might be a way to override this in Bazel: https://github.com/bazelbuild/bazel/blob/7.2.1/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModTidyFunction.java#L69. However, it's not totally clear to me if a workaround is currently possible. Since you've implemented a related feature (https://github.com/bazelbuild/bazel/pull/21265), I figured this would be the right place to bring it up.

Thanks!

fmeum commented 3 months ago

Thanks for the detailed feature request! We can certainly add this capability if we can't find a better solution for your use case.

The motivation behind fetching a pinned version of buildozer in the first place is to ensure that bazel mod tidy formats end edits consistently across different developer's machines working on a single project. By introducing the capability to use buildozer from the host, that guarantee is lost.

A proxy that allows you to go install arbitrary things but blocks all .exe downloads does, admittedly, sound a bit inconsistent. In a more restricted environment, using buildozer from the host may again not be convenient.

Because of this, I would first like to explore alternatives. A downloader config is one that's pretty standard. Does it work for you? If not, could you see bazel vendor being an alternative, which would allow you to vendor the buildozer binaries into your repo while still having them managed by Bazel?