Skip to content

When using rules_python 1.8.x with rules_mypy on Windows (Bazel 8.x), whl_library extraction fails聽#3543

Closed

Description

@vadikmironov

馃悶 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

Activity

  1. aignas commented on Jan 27, 2026

    @aignas
    Collaborator

    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.

  2. added a commit that references this issue on Jan 27, 2026
    6756f2a
  3. aignas commented on Jan 27, 2026

    @aignas
    Collaborator

    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.

  4. vadikmironov commented on Jan 27, 2026

    @vadikmironov
    ContributorAuthor

    @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:

    Build succeeded and the output is Hello, World!. The fix from PR #3549 resolves the Windows whl extraction issue. Here's a summary:                                  
    
      - Cloned aignas/rules_python branch aignas.fix.pipstar-extract-windows to D:/dev/projects/rules_python_aignas_fix
      - Added local_path_override for rules_python in MODULE.bazel pointing to the cloned fix
      - Installed PowerShell 7 (required by the development branch)
      - bazel run apps:hello completed successfully with output Hello, World! - no whl extraction errors
    
  5. vadikmironov commented on Jan 27, 2026

    @vadikmironov
    ContributorAuthor

    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?

  6. added a commit that references this issue on Jan 27, 2026
    abe2699
  7. rickeylev commented on Jan 27, 2026

    @rickeylev
    Collaborator

    use more compatible PowerShell.exe instead of pwsh.exe

    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.

  8. vadikmironov commented on Jan 27, 2026

    @vadikmironov
    ContributorAuthor

    Thanks @rickeylev . Shall I open a new issue then?

  9. added a commit that references this issue on Jan 28, 2026
    0057883
  10. rickeylev commented on Jan 28, 2026

    @rickeylev
    Collaborator

    Yes, please do. Happy to approve a PR, too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions