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

[Bug]: cannot use py_venv #331

Closed
KoltesDigital opened this issue Apr 16, 2024 · 8 comments
Closed

[Bug]: cannot use py_venv #331

KoltesDigital opened this issue Apr 16, 2024 · 8 comments
Assignees
Labels
bug Something isn't working repro needed Repro needed to proceed further

Comments

@KoltesDigital
Copy link

KoltesDigital commented Apr 16, 2024

What happened?

I've just added bazel_dep(name = "aspect_rules_py", version = "0.7.1") to make a venv, in a project where there already was rules_python with pip and so on: was working well.

But I'm unable to declare a py_venv:

ERROR: error loading package '@@aspect_rules_py~//py/tools/venv_bin': Unable to find package for @@[unknown repo 'rules_rust' requested from @@aspect_rules_py~]//rust:defs.bzl: The repository '@@[unknown repo 'rules_rust' requested from @@aspect_rules_py~]' could not be resolved: No repository visible as '@rules_rust' from repository '@@aspect_rules_py~'.
ERROR: X:/external/aspect_rules_py~/py/private/toolchain/venv/BUILD.bazel:3:17: error loading package '@@aspect_rules_py~//py/tools/venv_bin': Unable to find package for @@[unknown repo 'rules_rust' requested from @@aspect_rules_py~]//rust:defs.bzl: The repository '@@[unknown repo 'rules_rust' requested from @@aspect_rules_py~]' could not be resolved: No repository visible as '@rules_rust' 
from repository '@@aspect_rules_py~'. and referenced by '@@aspect_rules_py~//py/private/toolchain/venv:venv_toolchain_source'

I tried to untangle the code to find the dependency chain, but I'm out of luck.

Version

Development (host) and target OS/architectures: windows amd64

Output of bazel --version: bazel 7.1.1

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:
bazel_dep(name = "aspect_rules_py", version = "0.7.1")
bazel_dep(name = "rules_python", version = "0.31.0")

Language(s) and/or frameworks involved: N/A

How to reproduce

Simply put

load("@aspect_rules_py//py:defs.bzl", "py_venv")

py_venv(
    name = "venv",
)

and build it.

Any other information?

I'm migrating to bzlmod: my WORKSPACE is empty.

@KoltesDigital KoltesDigital added the bug Something isn't working label Apr 16, 2024
@github-actions github-actions bot added the untriaged Requires traige label Apr 16, 2024
@mattem
Copy link
Collaborator

mattem commented Apr 18, 2024

Do you have the toolchain setup? https://github.com/aspect-build/rules_py/blob/main/e2e/use_release/MODULE.bazel#L8-L10

It's missing from the setup on the releases page, will add.

@alexeagle
Copy link
Member

I'm not able to reproduce.

rules_py_snip % bazel build :all
INFO: Analyzed target //:venv (80 packages loaded, 2585 targets configured).
INFO: Found 1 target...
Target //:venv up-to-date:
  bazel-bin/venv
  bazel-bin/venv.venv.pth
INFO: Elapsed time: 2.189s, Critical Path: 0.33s
INFO: 6 processes: 6 internal.
INFO: Build completed successfully, 6 total actions

alexeagle@MacBook-Pro-79 rules_py_snip % cat .bazelversion 
7.1.1
alexeagle@MacBook-Pro-79 rules_py_snip % cat BUILD 
load("@aspect_rules_py//py:defs.bzl", "py_venv")

py_venv(
    name = "venv",
)
alexeagle@MacBook-Pro-79 rules_py_snip % cat MODULE.bazel 
bazel_dep(name = "aspect_rules_py", version = "0.7.1")
bazel_dep(name = "rules_python", version = "0.31.0")
alexeagle@MacBook-Pro-79 rules_py_snip % cat WORKSPACE 

The fact that the error references rules_rust suggests that you're doing something unusual. As you can see from "Dependency Graph" on https://registry.bazel.build/modules/aspect_rules_py/0.7.1 there is no dependency from rules_py to rules_rust, only a devDependency.

@alexeagle alexeagle added the repro needed Repro needed to proceed further label Apr 21, 2024
@alexeagle
Copy link
Member

@mattem the toolchain declaration is provided by the rules_py module here:
https://github.com/aspect-build/rules_py/blob/main/MODULE.bazel#L21
that's not a devDependency; it should also function for users. I don't have a theory why @KoltesDigital is seeing this error.

@jgsogo
Copy link

jgsogo commented Apr 27, 2024

Hi! I found the same issue in one repo I'm working on when trying to build it on a Windows machine. I was able to reproduce it with this minimal project: https://github.com/jgsogo/rules_py-331

bazel build //...

...
Starting local Bazel server and connecting to it...
ERROR: error loading package '@@aspect_rules_py~//py/tools/venv_bin': Unable to find package for @@[unknown repo 'rules_rust' requested from @@aspect_rules_py~]//rust:defs.bzl: The repository '@@[unknown repo 'rules_rust' requested from @@aspect_rules_py~]' could not be resolved: No repository visible as '@rules_rust' from repository '@@aspect_rules_py~'.
ERROR: C:/users/jgsog/_bazel_jgsog/lcqsxfsl/external/aspect_rules_py~/py/private/toolchain/venv/BUILD.bazel:3:17: error loading package '@@aspect_rules_py~//py/tools/venv_bin': Unable to find package for @@[unknown repo 'rules_rust' requested from @@aspect_rules_py~]//rust:defs.bzl: The repository '@@[unknown repo 'rules_rust' requested from @@aspect_rules_py~]' could not be resolved: No repository visible as '@rules_rust' from repository '@@aspect_rules_py~'. and referenced by '@@aspect_rules_py~//py/private/toolchain/venv:venv_toolchain_source'
Target //tooling/python:_version_default.find_main up-to-date (nothing to build)
ERROR: Analysis of target '//tooling/python:version_default' failed; build aborted: Analysis failed
INFO: Elapsed time: 5.599s, Critical Path: 0.06s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
FAILED:
    Fetching repository @@rules_python~~python~python_3_12_x86_64-pc-windows-msvc; starting

This is an "old" computer running Windows 10.

@mattem
Copy link
Collaborator

mattem commented Apr 29, 2024

@jgsogo rules_py doesn't publish / support windows yet, this is expected.

Consider donating to the project if you would like to fund Windows support, #237 (comment)

@alexeagle
Copy link
Member

oh X:/external I missed the windows path in that original post 🤦🏻

@mattem
Copy link
Collaborator

mattem commented Apr 29, 2024

Closing as this falls in the "windows isn't supported" category, repro works as expected on supported platforms.

@mattem mattem closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2024
@KoltesDigital
Copy link
Author

Oops, wasn't aware of that. Thanks anyway :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working repro needed Repro needed to proceed further
Projects
None yet
Development

No branches or pull requests

4 participants