bazelbuild / rules_pkg

Bazel rules for creating packages of many types (zip, tar, deb, rpm, ...)
Apache License 2.0
212 stars 166 forks source link

Unable to find package for @rules_python_internal//:rules_python_config.bzl: The repository '@rules_python_internal' could not be resolved: Repository '@rules_python_internal' is not defined. #872

Open ensonic opened 3 weeks ago

ensonic commented 3 weeks ago

WORKSPACE:

http_archive(
    name = "rules_pkg",
    sha256 = "d250924a2ecc5176808fc4c25d5cf5e9e79e6346d79d5ab1c493e289e722d1d0",
    urls = [
        "https://github.com/bazelbuild/rules_pkg/releases/download/0.10.1/rules_pkg-0.10.1.tar.gz",
    ],
)

load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
rules_pkg_dependencies()

//src/bootstrap/cloud/BUILD:

...

pkg_tar(
    name = "files",
    srcs = [
        "//:config.sh.tmpl",
        "//src/bootstrap/cloud/terraform",
    ],
    mode = "644",
    strip_prefix = "/",
)

Error:

bazel test //...
Starting local Bazel server and connecting to it...
INFO: Streaming build results to: <redacted>
ERROR: Analysis of target '//src/bootstrap/cloud:files' failed; build aborted: error loading package '@rules_pkg//pkg/private': at /usr/local/google/home/ensonic/.cache/bazel/_bazel_ensonic/88cafc24ebbba21bc2294727bc8fc64d/external/rules_python/python/defs.bzl:21:6: at /usr/local/google/home/ensonic/.cache/bazel/_bazel_ensonic/88cafc24ebbba21bc2294727bc8fc64d/external/rules_python/python/py_runtime_info.bzl:17:6: Unable to find package for @rules_python_internal//:rules_python_config.bzl: The repository '@rules_python_internal' could not be resolved: Repository '@rules_python_internal' is not defined.

We're not using any rules_python in the repo. This issue is blocking https://github.com/googlecloudrobotics/core/pull/373

aiuto commented 3 weeks ago

This looks like a python problem. You should probably pin to a newer rules python in your WORKSPACE or MODULE.bazel

ensonic commented 3 weeks ago

We're not using any rules_python like I said: https://github.com/googlecloudrobotics/core/blob/main/WORKSPACE

aiuto commented 3 weeks ago

Sure, but you are using other things. Everything you bring in to your WORKSPACE can impact what bzlmod resolves all the transitive dependencies too. Sometimes you just have to force things to specific versions in your project.

ensonic commented 3 weeks ago

So what rules_python version do you need to pkg_tar, just add it to you readme and I am happy to apply that workaround

ensonic commented 3 weeks ago

I see the python deps from the query: https://github.com/search?q=repo%3Abazelbuild%2Frules_pkg%20rules_python&type=code

aiuto commented 3 weeks ago

The one in MODULE.bazel or WORKSPACE should work. Probably everything newer than that does too. But that is not a requirement, nor even a recommendation. There is no way to know from the point of view of rules_pkg, what version of rules_python that you need to interoperate with all the other things you need. This is a Bazel ecosystem wide problem.

A reasonable practice for an end user is:

And then juggle that around until it works. But there are problems, because the add dependencies methods are sometimes written with maybe() style loads, and sometimes not. So possibly a_x_dependencies() will override your previously specified choice.

If I were building a product with Bazel, I would use the workspace tools only to query out what I need, and explicitly specify the versions of every transitive module required. That way I know that updating, for example, rules_python, won't change the version of rules_proto that I use.