Repository navigation
When using rules_python 1.8.x with rules_mypy on Windows (Bazel 8.x), whl_library extraction fails聽#3543
Copy link
Copy link
Closed
Description
馃悶 bug report
Affected Rule
The issue is likely to be caused by the _extract in repo_utils.bzl when called from whl_extract.bzl which in turn is called from whl_library.bzl
Is this a regression?
Yes, the previous version in which this bug was not present was: 1.7.0
Description
When using rules_python 1.8.x with rules_mypy on Windows (Bazel 8.x), whl_library extraction fails to extract packages from rules_mypy requirements.
馃敩 Minimal Reproduction
Following repository contains minimum reproduction scenario tested on Windows 11 with Bazel 8.5.1:
https://github.com/vadikmironov/rules_python_1.8.x_repro
馃敟 Exception or Error
INFO: Repository rules_python++pip+rules_mypy_pip_312_mypy instantiated at:
: in
Repository rule whl_library defined at:
C:/users/user/_bazel_user/rzsptrcq/external/rules_python+/python/private/pypi/whl_library.bzl:689:30: in
ERROR: C:/users/user/_bazel_user/rzsptrcq/external/rules_python+/python/private/repo_utils.bzl:446:18: An error occurred during the fetch of repository 'rules_python++pip+rules_mypy_pip_312_mypy':
Traceback (most recent call last):
File "C:/users/user/_bazel_user/rzsptrcq/external/rules_python+/python/private/pypi/whl_library.bzl", line 410, column 20, in _whl_library_impl
whl_extract(rctx, whl_path = whl_path, logger = logger)
File "C:/users/user/_bazel_user/rzsptrcq/external/rules_python+/python/private/pypi/whl_extract.bzl", line 16, column 23, in whl_extract
repo_utils.extract(
File "C:/users/user/_bazel_user/rzsptrcq/external/rules_python+/python/private/repo_utils.bzl", line 446, column 18, in _extract
mrctx.extract(
Error in extract: Cannot write outside of the repository directory for path C:/Users/user/_bazel_user/rzsptrcq/external/rules_python++pip+rules_mypy_pip_312_mypy/site-packages
ERROR: no such package '@@rules_python++pip+rules_mypy_pip_312_mypy//': Cannot write outside of the repository directory for path C:/Users/user/_bazel_user/rzsptrcq/external/rules_python++pip+rules_mypy_pip_312_mypy/site-packages
ERROR: C:/users/user/_bazel_user/rzsptrcq/external/rules_python++pip+rules_mypy_pip/mypy/BUILD.bazel:5:12: @@rules_python++pip+rules_mypy_pip//mypy:pkg depends on @@rules_python++pip+rules_mypy_pip_312_mypy//:pkg in repository @@rules_python++pip+rules_mypy_pip_312_mypy which failed to fetch. no such package '@@rules_python++pip+rules_mypy_pip_312_mypy//': Cannot write outside of the repository directory for path C:/Users/user/_bazel_user/rzsptrcq/external/rules_python++pip+rules_mypy_pip_312_mypy/site-packages
Target //apps:hello failed to build
馃實 Your Environment
Operating System:
Windows 11 25H2 26200.7623
Output of bazel version:
Bazelisk version: v1.28.1
Build label: 8.5.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Jan 12 18:43:11 2026 (1768243391)
Build timestamp: 1768243391
Build timestamp as int: 1768243391
Rules_python version:
1.8.2
Anything else relevant?
Works perfectly fine on rules_python 1.7.0. Reviewing the change log following change looks relevant: #3452
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
aignas commentedon Jan 27, 2026
Thank you for raising this issue. Could you please give us a little more diagnostic information? Where would be the repository path by default? If you remove the repository cache flag does it change something? What about the symlinks flag? It would be good to understand what is the minimal bazelrc that is causing this.
We don't see this error in our CI and I would be keen on covering this edge case. I have a temporary fix in mind where we could check if we are on Windows and disable starlark extraction logic. That would give us more time to investigate potential workarounds for Windows.
fix(pip): simply extract whl contents to the current directory
aignas commentedon Jan 27, 2026
I don't have a Windows machine and it would be of great help if you could test out the #3549 PR, that I have just made.
vadikmironov commentedon Jan 27, 2026
@aignas , thanks a lot. The fix works with reproduction repository! Worth noting that your fix is based on master and thus depends on pwsh.exe (PowerShell Core). Here are the notes from the agent:
vadikmironov commentedon Jan 27, 2026
If it helps and I am also not a Windows expert, but I think what comes by default is Windows PowerShell edition (v5.1-) with PowerShell.exe binary. For better compatibility and maybe for better dev experience it would be great to have build_data_writer.ps1 to maybe run on default stock PowerShell here?
fix(pip): simply extract whl contents to the current directory (#3549)
rickeylev commentedon Jan 27, 2026
SGTM. From some quick searching, it looks like powershell.exe (powershell 5) is pre-installed on windows, but pwsh.exe (power shell 7) isn't.
vadikmironov commentedon Jan 27, 2026
Thanks @rickeylev . Shall I open a new issue then?
fix(pip): simply extract whl contents to the current directory (#3549)
rickeylev commentedon Jan 28, 2026
Yes, please do. Happy to approve a PR, too