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 dependencies are not visible in WORKSPACE file #16197

Closed
cameron-martin opened this issue Aug 31, 2022 · 4 comments
Closed

Bzlmod dependencies are not visible in WORKSPACE file #16197

cameron-martin opened this issue Aug 31, 2022 · 4 comments
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests more data needed P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request

Comments

@cameron-martin
Copy link
Contributor

cameron-martin commented Aug 31, 2022

Description of the bug:

Repositories loaded via bzlmod are not available in the WORKSPACE file for loading macros from. Although I believe the intention is for bzlmod to fully replace WORKSPACE macros, it is convenient to have a mixture during the transition phase.

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

An example is available in this github repo: https://github.com/cameron-martin/bzlmod-workspace-repro

If you run bazel build //... in the root module, I get the following error:

ERROR: Failed to load Starlark extension '@sub_module//:foo.bzl'.
Cycle in the workspace file detected. This indicates that a repository is used prior to being defined.
The following chain of repository dependencies lead to the missing definition.
 - @sub_module
This could either mean you have to add the '@sub_module' repository with a statement like `http_archive` in your WORKSPACE file (note that transitive dependencies are not added automatically), or move an existing definition earlier in your WORKSPACE file.
ERROR: cycles detected during target parsing
INFO: Elapsed time: 0.030s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

However, I would expect the @sub_module repository to be loaded by bzlmod and available in the WORKSPACE file.

Which operating system are you running Bazel on?

Ubuntu 20.04

What is the output of bazel info release?

release 5.3.0

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

I also tried using the latest green, using bazelisk and I still get the same error

2022/08/31 20:10:14 Using unreleased version at commit dcc54d5ddb567b7c93af4a7dcd5f77e7b56fdc72
development version

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

No response

Have you found anything relevant by searching the web?

No, I didn't.

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

No response

@ShreeM01 ShreeM01 added type: bug team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. untriaged area-Bzlmod Bzlmod-specific PRs, issues, and feature requests labels Sep 1, 2022
@Wyverald
Copy link
Member

Wyverald commented Sep 2, 2022

This is not supported by design. You could write a module extension to call the macro you'd otherwise call.

What is your expected use case?

@Wyverald Wyverald added type: feature request P2 We'll consider working on this in future. (Assignee optional) more data needed and removed type: bug untriaged labels Sep 2, 2022
@cameron-martin
Copy link
Contributor Author

Thanks for clarifying that this is intentional.

My use case is to allow intermediate working states while transitioning a package to using bzlmod, where I can have some dependencies specified in MODULE.bzl, but others specified in the WORKSPACE file.

Specifically, this issue arose when attempting to add support for bzlmod to rules_rust. At least to somebody fairly unfamiliar with bzlmod adding this support is non-trivial, and being able to test while only some dependencies are specified via bzlmod and others via the WORKSPACE file is useful.

@meteorcloudy
Copy link
Member

From WORKSPACE, you can actually see the Bzlmod repos under their canonical repo name, for example

load("@@sub_module~override//:foo.bzl", "do_nothing")

Maybe this is useful for testing purpose, but you certainly shouldn't depend on it.

Also see the WORKSPACE.bzlmod support here.

@cameron-martin
Copy link
Contributor Author

Thanks, this is sufficient for my use case. I'll close this.

@cameron-martin cameron-martin closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 2022
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 more data needed P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request
Projects
None yet
Development

No branches or pull requests

4 participants