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

Platforms fail to resolve in modules #18616

Closed
mtribiere opened this issue Jun 8, 2023 · 10 comments
Closed

Platforms fail to resolve in modules #18616

mtribiere opened this issue Jun 8, 2023 · 10 comments
Labels
awaiting-user-response Awaiting a response from the author team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug untriaged

Comments

@mtribiere
Copy link

mtribiere commented Jun 8, 2023

Description of the bug:

I have a Bazel project (TEST_PARTITION) that loads a module (BUILD_TOOLS_RELOADED V0.0.1), and this module defines a platforms:
In the BUILD:

platform(
    name = "myPlatform",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:ppc",
	],
)

With the command :

bazel build //:TEST_BIN --platforms=@build_tools_reloaded//:myPlatform --enable_bzlmod

But get the following error:

ERROR: C:/tools/dev/bazel_install/6fao65yg/external/build_tools_reloaded~0.0.1/BUILD:6:9: no such package '@[unknown repo 'platforms' requested from @build_tools_reloaded~0.0.1]//cpu': The repository '@[unknown repo 'platforms' requested from @build_tools_reloaded~0.0.1]' could not be resolved: No repository visible as '@platforms' from repository '@build_tools_reloaded~0.0.1' and referenced by '@build_tools_reloaded~0.0.1//:myPlatform'
ERROR: C:/tools/dev/test_partition/BUILD:77:10: Analysis failed
ERROR: Analysis of target '//:TEST_BIN' failed; build aborted
INFO: Elapsed time: 14.702s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

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

My module build_tools_reloaded BUILD:

platform(
    name = "myPlateform",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:ppc",
	],
)

My project MODULE.bazel :

bazel_dep(name = "build_tools_reloaded", version = "0.0.1", repo_name = "build_tools_reloaded")

Which operating system are you running Bazel on?

Windows

What is the output of bazel info release?

release 6.2.0

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 ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

#17655
#17707

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

No response

@mtribiere
Copy link
Author

As a follow-up, If I add --override_module=build_tools_reloaded=..\BUILD_TOOLS_RELOADED to my command, it does work flawlessly.

This local folder BUILD_TOOLS_RELOADED is a direct clone from the git repo, so I guess the issue only affects packages that are downloaded from a bazel-registry

@Wyverald
Copy link
Member

Wyverald commented Jun 8, 2023

No repository visible as '@platforms' from repository '@build_tools_reloaded~0.0.1' and referenced by '@build_tools_reloaded~0.0.1//:myPlatform'

What does the MODULE.bazel file of your build_tools_reloaded module look like? Does it have a dependency on platforms?

@mtribiere
Copy link
Author

Yes it does, here it is:
MODULES.bazel:

module(
    name = "build_tools_reloaded",
    version = "0.0.1",
)
bazel_dep(name="platforms", version="0.0.5")

@Wyverald
Copy link
Member

Wyverald commented Jun 8, 2023

could you double-check that the MODULE.bazel for build_tools_reloaded on your registry has the correct contents?

If it does, I don't see any reason why this error would be thrown. Could you provide a minimal repro case?

@Wyverald Wyverald added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-user-response Awaiting a response from the author labels Jun 8, 2023
@mtribiere
Copy link
Author

In the bazel-central-registry/build_tools_reloaded repo I have the following :
MODULE.bazel:

module(
    name = "build_tools_reloaded",
    version = "0.0.1",
)

presubmit.yml :

matrix:
  platform: ["debian11", "macos", "ubuntu2004"]
tasks:
  verify_targets:
    name: Verify build targets
    platform: ${{ platform }}
    build_targets:
    - '@build_tools_reloaded//...'

source.json:

{
    "url": "http://myserver.com/to/path/to/build_tools_reloaded.zip",
    "integrity": "sha256-iVq24xidG3dQ5idQtRDYBiZvo2v9DnbLb0n32uvP3qo=",
    "patches": {
    },
    "strip_prefix": "build_tools_reloaded",
    "patch_strip": 0
}

@mtribiere
Copy link
Author

mtribiere commented Jun 9, 2023

I actually had a question: There is 2 MODULE.bazel one in the bazel registry and one in the actual repo but how does that works? Do one override the other, do they get added to each other...

@mtribiere
Copy link
Author

I get a different error this morning:

ERROR: C:/tools/dev/bazel_install/6fao65yg/external/build_tools_reloaded~0.0.1/BUILD:6:9: no such package '@[unknown repo 'platforms' requested from @build_tools_reloaded~0.0.1]//os': The repository '@[unknown repo 'platforms' requested from @build_tools_reloaded~0.0.1]' could not be resolved: No repository visible as '@platforms' from repository '@build_tools_reloaded~0.0.1' and referenced by '@build_tools_reloaded~0.0.1//:myPlatform'
ERROR: C:/tools/dev/test_partition/BUILD:77:10: While resolving toolchains for target //:TEST_BIN: Target @build_tools_reloaded~0.0.1//:myPlatform was referenced as a platform, but does not provide PlatformInfo
ERROR: Analysis of target '//:TEST_BIN' failed; build aborted:
INFO: Elapsed time: 0.393s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

I have no clue what's happening

@fmeum
Copy link
Collaborator

fmeum commented Jun 9, 2023

The MODULE.bazel file in the registry is the one that matters, which is probably also why you are seeing this error - it lacks a bazel_dep on platforms.

The MODULE.bazel file in the source archive should match the file in the registry. This is enforced by BCR tooling, but not in Bazel itself.

@mtribiere
Copy link
Author

Oh that's probably why!
Maybe there's room for improvement here, having duplicate information isn't the best thing. Especially if there is 2 teams working on this, there could be issues

@mtribiere
Copy link
Author

It's working closing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-response Awaiting a response from the author team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug untriaged
Projects
None yet
Development

No branches or pull requests

5 participants