Python 3.13 Virtual Environment Path Incompatibility on Windows

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • DevProd Correctness
    • Fully Compatible
    • Correctness 2026-01-12, Correctness 2026-01-26
    • 0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Python 3.13 Virtual Environment Path Incompatibility on Windows

      Problem

      After upgrading Windows Python from 3.10 to 3.13, Poetry creates its own virtualenv instead of using the activated venv in Evergreen CI. This causes Poetry to install dependencies in the wrong location, breaking the build.

      Root Cause

      Python 3.11.4+ introduced a change to the venv activation script that automatically converts Windows paths to Cygwin format when running under Cygwin/MSYS bash (which Evergreen uses on Windows).

      What Changed:

      Python 3.10: VIRTUAL_ENV=C:\data\mci\6409\venv (Windows path)
      Python 3.13: VIRTUAL_ENV=/cygdrive/c/data/mci/6409/venv (Cygwin path)
      

      Why This Breaks Poetry:

      Poetry detects if it's running in a virtual environment by comparing the VIRTUAL_ENV environment variable to sys.prefix. However:

      VIRTUAL_ENV is now a Cygwin path: /cygdrive/c/data/mci/6409/venv
      sys.prefix is always a Windows path: C:\data\mci\6409\venv
      

      These paths don't match, so Poetry thinks it's not in a venv and creates its own.

      Python Upstream Issue

      This behavior was intentionally added in Python 3.11.4 to fix venvs not working across different drives on Windows.

      References:

      Affected Python Versions:

      • Python 3.11.4+
      • Python 3.12.0+
      • Python 3.13.0+

      Observed Behavior

      From Evergreen logs:

      [2026/01/12 12:52:52.238] DEBUG: VIRTUAL_ENV variable: /cygdrive/c/data/mci/6409/venv
      [2026/01/12 12:52:52.238] DEBUG: sys.prefix: C:\data\mci\6409\venv
      [2026/01/12 12:52:53.902] Creating virtualenv mdb-python-deps-gAD-pCWv-py3.13 in C:\data\mci\6409\poetry_dir\cache\virtualenvs
      

      Poetry creates a new venv because the paths don't match.

            Assignee:
            Nicholas Jefferies
            Reporter:
            Nicholas Jefferies
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: