ITADN

Incompatibility between Windows env vars and the shell

#2786Closedprosilio 创建于 2026-03-19
P
prosiliocommented
### Description Two closely related issues rolled into one. The first is a minor nit on the documentation. The second is a problem with the build environment. At the end, I share my workaround. ## Documentation Per the `environment` [documentation](https://cibuildwheel.pypa.io/en/stable/options/#environment), "Bash syntax should be used, even on Windows." However, the example uses Windows-style backslashes and a semicolon separator rather than a colon: ``` # Prepend a directory containing spaces on Windows. [tool.cibuildwheel.windows] environment = { PATH='C:\\Program Files\\PostgreSQL\\13\\bin;$PATH' } ``` Per the next issue, I think that the example Windows-style `environment` is correct. ## Env var/shell incompatibility Windows builds run in a cmd.exe shell, but environment variables specified with `$(pwd)` in `CIBW_ENVIRONMENT_WINDOWS`/`environment` come out Unix-style, which means that cmd doesn't know what to do with them. Here's an example: ``` [tool.cibuildwheel.windows] environment = { VCPKG_ROOT="$(pwd)/vcpkg", PATH="$VCPKG_ROOT:$PATH" } before-all = [ "echo %VCPKG_ROOT%", # Clone and install vcpkg... ] # Result of "echo %VCPKG_ROOT%": # /d/a/workflows/workflows/vcpkg ``` Now, if I change my configuration to the following, then all is well. ``` [tool.cibuildwheel.windows] environment = { VCPKG_ROOT='D:\\a\\workflows\\workflows\\vcpkg', PATH="$VCPKG_ROOT;$PATH" } before-all = [ "echo %VCPKG_ROOT%", # Clone and install vcpkg... ] ``` That's not so bad, except that we lose the use of `$(pwd)`, and we just have to hope that the `D:\a\workflows\workflows` path won't change. ## Workaround I was going to clone vcpkg into `C:\vcpkg` and point my env vars there, but, surprisingly, I found that vcpkg is already installed there. **EDIT**: If I had bothered to check the [GitHub documentation](https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md), I wouldn't have been so surprised at finding vcpkg there. ### Build log _No response_ ### CI config _No response_
关闭于 2026-03-19 2 条评论