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]: bazel-runfiles pypi library does not work #377

Open
dizzy57 opened this issue Aug 6, 2024 · 2 comments
Open

[Bug]: bazel-runfiles pypi library does not work #377

dizzy57 opened this issue Aug 6, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@dizzy57
Copy link

dizzy57 commented Aug 6, 2024

What happened?

bazel-runfiles library is unable to properly locate runfiles root when running under rules_py

Version

Development (host) and target OS/architectures: macOS aarch64, also seen on Linux x86_64

Output of bazel --version: bazel 7.2.1

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file: 0.7.4

Language(s) and/or frameworks involved: None

How to reproduce

git clone https://github.com/dizzy57/bazel_py_minimal
cd bazel_py_minimal
bazel test //runfiles_from_pipy_do_not_work/...

Expected result: all tests pass
Actual result: //runfiles_from_pipy_do_not_work:runfiles_test fails with a message
ValueError: [PREFIX]/runfiles_test.runfiles/_main/runfiles_from_pipy_do_not_work/test_runfiles.py does not lie under the runfiles root [PREFIX]/runfiles_test.runfiles/.runfiles_test.venv/lib

Any other information?

Same test passes with rules_python: see bazel test //runfiles_from_pipy_do_not_work:runfiles_rp_test

Exception source in runfiles.py (rules_python v0.34.0)

The python.runfiles package from @rules_python//python/runfiles works, see bazel test //runfiles_from_pipy_do_not_work:runfiles_rfrp_test //runfiles_from_pipy_do_not_work:runfiles_rp_rfrp_test

This problem was introduced in rules_py v0.7.2

@dizzy57 dizzy57 added the bug Something isn't working label Aug 6, 2024
@mattem
Copy link
Collaborator

mattem commented Aug 9, 2024

This is a rules_python issue I think, as the runfiles helper is walking up the directory structure to attempt to determine the runfiles root, which under the venv (or any other layout) is not correct. The diff here shows a potential solution, but I'm not clear if this is correct, or what repercussions this has, I imagine Windows will have something to say about it.

bazelbuild/rules_python#2115

Continuing the discussion with other rules_python maintainers.

@Zemnmez
Copy link

Zemnmez commented Aug 29, 2024

I'm getting this same issue:

Traceback (most recent call last):
  File "/private/var/tmp/_bazel_tshadwell/f7d9bb6f07b31d1ba7eb0c999b8bb37b/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/py/ibazel/ibazel_bin.runfiles/_main/py/ibazel/__main__.py", line 18, in <module>
    ibazel_binary_path = path = r.Rlocation(environ["IBAZEL_BINARY"])
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/var/tmp/_bazel_tshadwell/f7d9bb6f07b31d1ba7eb0c999b8bb37b/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/py/ibazel/ibazel_bin.runfiles/.ibazel_bin.venv/lib/python3.11/site-packages/runfiles/runfiles.py", line 175, in Rlocation
    source_repo = self.CurrentRepository(frame=2)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/var/tmp/_bazel_tshadwell/f7d9bb6f07b31d1ba7eb0c999b8bb37b/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/py/ibazel/ibazel_bin.runfiles/.ibazel_bin.venv/lib/python3.11/site-packages/runfiles/runfiles.py", line 264, in CurrentRepository
    raise ValueError(
ValueError: /private/var/tmp/_bazel_tshadwell/f7d9bb6f07b31d1ba7eb0c999b8bb37b/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/py/ibazel/ibazel_bin.runfiles/_main/py/ibazel/__main__.py does not lie under the runfiles root /private/var/tmp/_bazel_tshadwell/f7d9bb6f07b31d1ba7eb0c999b8bb37b/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/py/ibazel/ibazel_bin.runfiles/.ibazel_bin.venv/lib

@mattem mattem self-assigned this Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants