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

--enable_bzlmod breaks toolchain resolution for toolchains registered in WORKSPACE #17289

Closed
gregmagolan opened this issue Jan 20, 2023 · 10 comments
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@gregmagolan
Copy link
Contributor

gregmagolan commented Jan 20, 2023

Description of the bug:

Setting the --enable_bzlmod flag (even with an empty MODULE.bazel file) breaks toolchain resolution for toolchains registered in the WORKSPACE file.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

https://github.com/gregmagolan/repro-enable_bzlmod_breaks_workspace

Which operating system are you running Bazel on?

MacOS

What is the output of bazel info release?

release 6.0.0

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

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

https://github.com/gregmagolan/repro-enable_bzlmod_breaks_workspace

Have you found anything relevant by searching the web?

Searched through Bazel issues and didn't see any duplicates.

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

@katre
Copy link
Member

katre commented Jan 20, 2023

This feels to be Working As Intended, since modules specifically have a different way to register toolchains, but I'll leave it for @Wyverald to clarify.

@gregmagolan
Copy link
Contributor Author

gregmagolan commented Jan 20, 2023

I passed this by @Wyverald on Bazel Slack and he asked to create an issue and cc him. Was just trying to find his GitHub handle :)

If WORKSPACE files can't register toolchains when bzlmod is enabled then it will be hard to use rulesets that have bzlmod support alongside rulesets that don't (while they all get up to speed) if they both register toolchains.

gregmagolan added a commit to aspect-build/aspect-cli that referenced this issue Jan 20, 2023
It's a bit early for this. `--enable_bzlmod` is not on by default in
Bazel 6 and bzlmod still has many bugs such as
bazelbuild/bazel#17289. We could add it back
in a follow-up as an opt-in via a `aspect init --bzlmod` flag or via
part of the wizard. We could also stamp out bzlmod and WORKSPACE
boilerplate for rule sets as opt-ins via flags or wizards similar to how
other tools create wizards work.

GitOrigin-RevId: 2b7157d08d4acf2f7b72ac227c776257b9ae9137
gregmagolan added a commit to aspect-build/aspect-cli that referenced this issue Jan 20, 2023
It's a bit early for this. `--enable_bzlmod` is not on by default in
Bazel 6 and bzlmod still has many bugs such as
bazelbuild/bazel#17289. We could add it back
in a follow-up as an opt-in via a `aspect init --bzlmod` flag or via
part of the wizard. We could also stamp out bzlmod and WORKSPACE
boilerplate for rule sets as opt-ins via flags or wizards similar to how
other tools create wizards work.

GitOrigin-RevId: 2b7157d08d4acf2f7b72ac227c776257b9ae9137
@sgowroji sgowroji added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. area-Bzlmod Bzlmod-specific PRs, issues, and feature requests untriaged type: bug labels Jan 21, 2023
Toxaris added a commit to Toxaris/papercraft-dungeon-generator that referenced this issue Jan 27, 2023
Only viable once all dependencies support it, see:
bazelbuild/bazel#17289
@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 30 days. It will be closed in the next 7 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler".

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 21, 2023
@brentleyjones
Copy link
Contributor

Not stale.

@sgowroji sgowroji removed the stale Issues or PRs that are stale (no activity for 30 days) label Feb 21, 2023
@Wyverald
Copy link
Member

Ah, I think I figured out what's wrong here. It's that damn platforms repo again...

When you don't enable Bzlmod, @platforms for everyone is the @@platforms repo defined in a WORKSPACE prefix/suffix (don't remember which). All good.

When you enable Bzlmod, @platforms is still the @@platforms repo defined in a WORKSPACE prefix/suffix for everything that is not in the Bzlmod system (i.e. all the WORKSPACE repos including @@rules_nodejs). However, for things in the Bzlmod system (i.e. only built-in modules like bazel_tools and local_config_platform because your MODULE.bazel file is empty), @platforms actually refers to @@platforms~0.0.5. This is important because when we search for an appropriate execution platform (most likely your host machine), @local_config_platform//:host actually uses the platforms defined in @@platforms~0.0.5, but rules_nodejs defines toolchains for platforms defined in @@platforms.

The immediate workaround would be to add a single line in your MODULE.bazel file (bazel_dep(name="platforms", version="0.0.5")). I'll have to ponder how we could resolve this situation better, if it's even possible.

@Wyverald Wyverald added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Feb 21, 2023
@Wyverald
Copy link
Member

Closing this as things are technically working as intended here. Hopefully the existence of this issue will serve as documentation for whoever's encountering this problem in the future.

@HappyCerberus
Copy link

Closing this as things are technically working as intended here. Hopefully the existence of this issue will serve as documentation for whoever's encountering this problem in the future.

Uhm, the module system not resolving a dependency, and the user having to manually depend on a specific version of a deep dependency is "working as intended"?

In my view this completely invalidates bzlmod.

It might be working "as designed", but definitely not "as intended".

@mtribiere
Copy link

mtribiere commented Jun 7, 2023

Agreed, letting the user add a dependency to make it work isn't really a solution to me.
To anyone that don't want to read the whole thing:
Add to MODULE.bazel:

bazel_dep(name="platforms", version="0.0.5")

@Wyverald Wyverald reopened this Jun 7, 2023
@Wyverald
Copy link
Member

Wyverald commented Jun 7, 2023

if anyone has an idea how to fix this, please leave a suggestion.

@mtribiere
Copy link

mtribiere commented Jun 8, 2023

Maybe making platforms v0.0.5 the default on Bazel 7 would be a solution ?

iancha1992 pushed a commit to iancha1992/bazel that referenced this issue Jun 12, 2023
The canonical repo name of the `platforms` module is now forced to be `platforms`, which ensures that `@platforms` constraints used by toolchains defined in `WORKSPACE` match those referenced by the auto-configured host platform provided by `local_config_platform`.

Fixes bazelbuild#17289

Closes bazelbuild#18624.

PiperOrigin-RevId: 539710874
Change-Id: I171f308b06e7ec7559641b49b4c8c53dddac0d3c
iancha1992 added a commit that referenced this issue Jun 13, 2023
The canonical repo name of the `platforms` module is now forced to be `platforms`, which ensures that `@platforms` constraints used by toolchains defined in `WORKSPACE` match those referenced by the auto-configured host platform provided by `local_config_platform`.

Fixes #17289

Closes #18624.

PiperOrigin-RevId: 539710874
Change-Id: I171f308b06e7ec7559641b49b4c8c53dddac0d3c

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
traversaro pushed a commit to traversaro/bazel that referenced this issue Jun 24, 2023
The canonical repo name of the `platforms` module is now forced to be `platforms`, which ensures that `@platforms` constraints used by toolchains defined in `WORKSPACE` match those referenced by the auto-configured host platform provided by `local_config_platform`.

Fixes bazelbuild#17289

Closes bazelbuild#18624.

PiperOrigin-RevId: 539710874
Change-Id: I171f308b06e7ec7559641b49b4c8c53dddac0d3c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants