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

Allow dev_dependency register_toolchains calls #18248

Closed
rickeylev opened this issue Apr 27, 2023 · 1 comment
Closed

Allow dev_dependency register_toolchains calls #18248

rickeylev opened this issue Apr 27, 2023 · 1 comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request untriaged

Comments

@rickeylev
Copy link
Contributor

Description of the feature request:

Allow register_toolchains(dev_dependency=True) so that MODULE files can register toolchains only necessary for development and testing.

The specific case I'm dealing with is documentation generation: generating docs for my code is a dev-time only activity, but it uses tools that use toolchains.

Unfortunately, any register_toolchains() call in my module will propagate to consumers. This puts me in a catch-22: if I add register_toolchains(), my users are broken (because it'll try to register toolchains that were never setup). If I don't add it, my docgen tools can't run.

This idea is easily expanded: One might have various tools only necessary for development purposes (lints, test runners, debuggers, type checkers, etc), and it makes sense those tools would rely on some language toolchain. But those toolchains aren't necessary for any users, nor should they depend on them in any way.

cc
@fmeum as he mentioned he proposed this idea in the past
@Wyverald pretty sure he owns bzlmod

What underlying problem are you trying to solve with this feature?

Making it possible to have dev-time only dependencies that rely on toolchains.

Which operating system are you running Bazel on?

linux

What is the output of bazel info release?

release 6.1.2

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

git@github.com:rickeylev/rules_testing.git
79fd58291d29e22fe92542ca8c35f4af9ee8021a
79fd58291d29e22fe92542ca8c35f4af9ee8021a

Have you found anything relevant by searching the web?

nothing found

Any other information, logs, or outputs that you want to share?

No response

@rickeylev
Copy link
Contributor Author

I'd also like to note this is rather hard to work around.

Fabian suggested creating an extension that creates a "middleman" repo. The extension detects if its the root module, and, if so, populates the middleman with references to the real toolchains. If not, then it puts a fake toolchain in so downstream users inheriting the register_toolchains() call don't break. Implementing this, however, is...well I haven't really figured out a good way, yet. You can't alias :all; alias() doesn't work with toolchains; symlinking the underlying build file introduces more complications with repo visibility. Maybe I'm missing something obvious, but it's turning into a headache.

@Pavank1992 Pavank1992 added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Apr 28, 2023
Wyverald pushed a commit that referenced this issue Apr 28, 2023
…18259)

Fixes #18248

Closes #18253.

PiperOrigin-RevId: 527858646
Change-Id: I544694bb55f466bd6e14660ae62f2d535c283563

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
fweikert pushed a commit to fweikert/bazel that referenced this issue May 25, 2023
Fixes bazelbuild#18248

Closes bazelbuild#18253.

PiperOrigin-RevId: 527858646
Change-Id: I544694bb55f466bd6e14660ae62f2d535c283563
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request untriaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants