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

bzlmod users should get a default toolchain registration #22

Open
alexeagle opened this issue Nov 21, 2023 · 5 comments
Open

bzlmod users should get a default toolchain registration #22

alexeagle opened this issue Nov 21, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@alexeagle
Copy link
Collaborator

There's a TODO introduced, see thread:
#17 (comment)

@p0deje
Copy link
Member

p0deje commented Jan 16, 2024

I've tried adding the default toolchain by adding the following to MODULE.bazel

ruby = use_extension("@rules_ruby//ruby:extensions.bzl", "ruby")
ruby.toolchain(
    name = "ruby",
    version = "jruby-9.4.5.0",
)
use_repo(ruby, "ruby", "ruby_toolchains")
register_toolchains("@ruby_toolchains//:all")

However, this fails as now there are multiple toolchains called ruby:

Error in fail: Multiple conflicting toolchains declared for name ruby (jruby-9.4.5.0, None) and ("", Label("//:.ruby-version"), ["libyaml"])

How multiple toolchain registrations should actually work? Is there any good example of this?

@p0deje p0deje added the enhancement New feature or request label Jan 23, 2024
@alexeagle
Copy link
Collaborator Author

That error is our own, in extensions.bzl doing logic that looks at the global view of all calls to the extension and decide what to do. I think it's just a logic bug that we should figure out how to disambiguate this case.

@kormide has been doing these fixes in our other rules lately and probably has some details easily recalled.

@kormide
Copy link

kormide commented Jan 30, 2024

You can follow what we do with toolchain registration in bazel-lib: https://github.com/aspect-build/bazel-lib/blob/main/lib/extensions.bzl#L110.

We use this private toolchain_repos_bfs utility to do the work.

@p0deje
Copy link
Member

p0deje commented Jan 31, 2024

@kormide Thank you for sharing, but the code in is quite similar to what ruby_rules already do and produce the same error. How would a user define a custom toolchain with a custom yq version in their MODULE? Do they need to use a different toolchain name?

@kormide
Copy link

kormide commented Feb 1, 2024

@kormide Thank you for sharing, but the code in is quite similar to what ruby_rules already do and produce the same error. How would a user define a custom toolchain with a custom yq version in their MODULE? Do they need to use a different toolchain name?

We write the toolchain module extension so that whatever version is specified in the root module overrides versions from other invocations in the dependency graph, as long as the repo "name" is the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants