bazel-contrib / bazel-contrib/rules_python

Runfiles API fails when code and output_user_root are on different Windows drives.

Đang mở
#2,141 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Starlark
Star
688
Fork
721
Merge trung bình
15 giờ 7 phút
Pull request đã merge (30 ngày)
76

Mô tả

# 🐞 bug report

### Affected Rule

`python.runfiles`

### Is this a regression?

I'm not sure, I've never seen it but I rarely use windows.

### Description

It seems if a repo is checked out to a different drive than the bazel output_base then the runfiles API breaks.

https://github.com/UebelAndre/rules_pytest/actions/runs/10495890608/job/29075336459

## 🔬 Minimal Reproduction

On https://github.com/UebelAndre/rules_pytest/tree/abb7f0e6598cb267a704e189237a14b5d777532d run:
```
bazel test //python/pytest/private/tests/version_test
```

## 🔥 Exception or Error

```
__________________________________________ test_versions __________________________________________
(19:07:33) INFO: Found 28 targets and 20 test targets...

def test_versions() -> None:
"""Test that the version.bzl and MOUDLE.bazel versions are synced."""
runfiles = Runfiles.Create()
if not runfiles:
raise EnvironmentError("Failed to locate runfiles.")

> version_bzl = rlocation(runfiles, "rules_pytest/version.bzl")

D:\a\rules_pytest\rules_pytest\python\pytest\private\tests\version_test\version_test.py:35:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
D:\a\rules_pytest\rules_pytest\python\pytest\private\tests\version_test\version_test.py:20: in rlocation
runfile = runfiles.Rlocation(rlocationpath)
..\rules_python\python\runfiles\runfiles.py:175: in Rlocation
source_repo = self.CurrentRepository(frame=2)
..\rules_python\python\runfiles\runfiles.py:248: in CurrentRepository
caller_runfiles_path = os.path.relpath(caller_path, self._python_runfiles_root)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

path = 'D:\\a\\rules_pytest\\rules_pytest\\python\\pytest\\private\\tests\\version_test\\version_test.py'
start = 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\Bazel.runfiles_ycjtfwtt\\runfiles'

> ???
E ValueError: path is on mount 'D:', start on mount 'C:'

:766: ValueError
```

## 🌍 Your Environment

**Operating System:**

  

windows

**Output of `bazel version`:**

  

Bazelisk version: 1.20.0
Build label: 7.3.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Aug 19 16:41:27 2024 (1724085687)
Build timestamp: 1724085687
Build timestamp as int: 1724085687

**Rules_python version:**

  

0.34.0

**Anything else relevant?**

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với python/runfiles/runfiles.py, đặc biệt là Rlocation và CurrentRepository, sau đó tái hiện lỗi bằng cách chạy bazel test //python/pytest/private/tests/version_test trên Windows, với repository và output root nằm trên các ổ đĩa khác nhau. Traceback của version_test.py cho thấy thao tác đường dẫn bị lỗi; công việc được hoàn tất khi việc tái hiện hoàn thành mà không có ValueError giữa các ổ đĩa và hành vi này được bao phủ bởi một test phù hợp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
build-system, tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.