Get environment suitable for PlatformIO execution. On Windows Git Bash: Returns clean environment without Git Bash indicators (strips MSYSTEM, TERM, SHELL, etc.) to prevent ESP-IDF toolchain errors. On other platforms: Returns UTF-8 environment (same as get_utf8_env()). This funct
()
| 23 | |
| 24 | |
| 25 | def get_pio_execution_env() -> dict[str, str]: |
| 26 | """Get environment suitable for PlatformIO execution. |
| 27 | |
| 28 | On Windows Git Bash: Returns clean environment without Git Bash indicators |
| 29 | (strips MSYSTEM, TERM, SHELL, etc.) to prevent ESP-IDF toolchain errors. |
| 30 | |
| 31 | On other platforms: Returns UTF-8 environment (same as get_utf8_env()). |
| 32 | |
| 33 | This function solves the ESP-IDF v5.5.x incompatibility with Git Bash: |
| 34 | "ERROR: MSys/Mingw is not supported. Please follow the getting started guide" |
| 35 | |
| 36 | Returns: |
| 37 | Environment dict suitable for running PlatformIO commands |
| 38 | """ |
| 39 | import os |
| 40 | |
| 41 | from ci.util.windows_cmd_runner import get_clean_windows_env, should_use_cmd_runner |
| 42 | |
| 43 | if should_use_cmd_runner(): |
| 44 | # Windows Git Bash: Use clean environment without Git Bash indicators |
| 45 | env = get_clean_windows_env() |
| 46 | else: |
| 47 | # Linux/Mac or native Windows shell: Use UTF-8 environment |
| 48 | env = get_utf8_env() |
| 49 | |
| 50 | # Verify PLATFORMIO_SRC_DIR is preserved (debugging) |
| 51 | if "PLATFORMIO_SRC_DIR" in os.environ and "PLATFORMIO_SRC_DIR" not in env: |
| 52 | # This should never happen - log error for debugging |
| 53 | import sys |
| 54 | |
| 55 | print( |
| 56 | "⚠️ WARNING: PLATFORMIO_SRC_DIR was set but not preserved in subprocess environment!", |
| 57 | file=sys.stderr, |
| 58 | ) |
| 59 | print( |
| 60 | f" Parent process has: PLATFORMIO_SRC_DIR={os.environ['PLATFORMIO_SRC_DIR']}", |
| 61 | file=sys.stderr, |
| 62 | ) |
| 63 | print(" This is a bug in get_pio_execution_env()", file=sys.stderr) |
| 64 | |
| 65 | return env |
| 66 | |
| 67 | |
| 68 | def create_building_banner(example: str) -> str: |
no test coverage detected