All of our build pipelines are failing due to what appears to be a bug with environment variable substitution in our tox.ini. The variable substitution works as expected with tox==3.27.1, but we start having issues with tox==4.0.9.
(.venv) C:\tmp\tox_4.0.9_bug>pip list
Package Version
------------- -------
cachetools 5.2.0
chardet 5.1.0
colorama 0.4.6
distlib 0.3.6
filelock 3.8.2
packaging 22.0
pip 22.3.1
platformdirs 2.6.0
pluggy 1.0.0
pyproject_api 1.2.1
setuptools 65.6.3
tomli 2.0.1
tox 4.0.9
virtualenv 20.17.1
wheel 0.38.4
(.venv) C:\tmp\tox_4.0.9_bug>tox -rvv
default: 2108 I find interpreter for spec PythonSpec(path=C:\tmp\tox_4.0.9_bug\.venv\Scripts\python.exe) [virtualenv\discovery\builtin.py:56]
default: 2134 D got python info of C:\Users\nws2293\AppData\Local\Programs\Python\Python39\python.exe from C:\Users\nws2293\AppData\Local\pypa\virtualenv\py_info\1\72aa99cb99a91779d7fa96aaf09f6d3b1207abe0138f99ab0af57c8a95fa9102.json [virtualenv\app_data\via_disk_folder.py:129]
default: 2173 I proposed PythonInfo(spec=CPython3.9.10.final.0-64, system=C:\Users\nws2293\AppData\Local\Programs\Python\Python39\python.exe, exe=C:\tmp\tox_4.0.9_bug\.venv\Scripts\python.exe, platform=win32, version='3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]', encoding_fs_io=utf-8-cp1252) [virtualenv\discovery\builtin.py:63]
default: 2174 D accepted PythonInfo(spec=CPython3.9.10.final.0-64, system=C:\Users\nws2293\AppData\Local\Programs\Python\Python39\python.exe, exe=C:\tmp\tox_4.0.9_bug\.venv\Scripts\python.exe, platform=win32, version='3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]', encoding_fs_io=utf-8-cp1252) [virtualenv\discovery\builtin.py:65]
default: 2203 D symlink on filesystem does not work [virtualenv\info.py:43]
default: 2207 D filesystem is not case-sensitive [virtualenv\info.py:24]
default: 2420 I create virtual environment via CPython3Windows(dest=C:\tmp\tox_4.0.9_bug\.tox\default, clear=False, no_vcs_ignore=False, global=False) [virtualenv\run\session.py:48]
default: 2422 D create folder C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages [virtualenv\util\path\_sync.py:9]
default: 2427 D create folder C:\tmp\tox_4.0.9_bug\.tox\default\Scripts [virtualenv\util\path\_sync.py:9]
default: 2429 D write C:\tmp\tox_4.0.9_bug\.tox\default\pyvenv.cfg [virtualenv\create\pyenv_cfg.py:30]
default: 2430 D home = C:\Users\nws2293\AppData\Local\Programs\Python\Python39 [virtualenv\create\pyenv_cfg.py:34]
default: 2431 D implementation = CPython [virtualenv\create\pyenv_cfg.py:34]
default: 2431 D version_info = 3.9.10.final.0 [virtualenv\create\pyenv_cfg.py:34]
default: 2432 D virtualenv = 20.17.1 [virtualenv\create\pyenv_cfg.py:34]
default: 2433 D include-system-site-packages = false [virtualenv\create\pyenv_cfg.py:34]
default: 2434 D base-prefix = C:\Users\nws2293\AppData\Local\Programs\Python\Python39 [virtualenv\create\pyenv_cfg.py:34]
default: 2434 D base-exec-prefix = C:\Users\nws2293\AppData\Local\Programs\Python\Python39 [virtualenv\create\pyenv_cfg.py:34]
default: 2434 D base-executable = C:\Users\nws2293\AppData\Local\Programs\Python\Python39\python.exe [virtualenv\create\pyenv_cfg.py:34]
default: 2439 D copy C:\Users\nws2293\AppData\Local\Programs\Python\Python39\Lib\venv\scripts\nt\python.exe to C:\tmp\tox_4.0.9_bug\.tox\default\Scripts\python.exe [virtualenv\util\path\_sync.py:36]
default: 2448 D copy C:\Users\nws2293\AppData\Local\Programs\Python\Python39\Lib\venv\scripts\nt\pythonw.exe to C:\tmp\tox_4.0.9_bug\.tox\default\Scripts\pythonw.exe [virtualenv\util\path\_sync.py:36]
default: 2466 D create virtualenv import hook file C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\_virtualenv.pth [virtualenv\create\via_global_ref\api.py:89]
default: 2473 D create C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\_virtualenv.py [virtualenv\create\via_global_ref\api.py:92]
default: 2480 D ============================== target debug ============================== [virtualenv\run\session.py:50]
default: 2481 D debug via 'C:\tmp\tox_4.0.9_bug\.tox\default\Scripts\python.exe' 'C:\tmp\tox_4.0.9_bug\.venv\lib\site-packages\virtualenv\create\debug.py' [virtualenv\create\creator.py:197]
default: 2480 D {
"sys": {
"executable": "C:\\tmp\\tox_4.0.9_bug\\.tox\\default\\Scripts\\python.exe",
"_base_executable": "C:\\Users\\nws2293\\AppData\\Local\\Programs\\Python\\Python39\\python.exe",
"prefix": "C:\\tmp\\tox_4.0.9_bug\\.tox\\default",
"base_prefix": "C:\\Users\\nws2293\\AppData\\Local\\Programs\\Python\\Python39",
"real_prefix": null,
"exec_prefix": "C:\\tmp\\tox_4.0.9_bug\\.tox\\default",
"base_exec_prefix": "C:\\Users\\nws2293\\AppData\\Local\\Programs\\Python\\Python39",
"path": [
"C:\\Users\\nws2293\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip",
"C:\\Users\\nws2293\\AppData\\Local\\Programs\\Python\\Python39\\DLLs",
"C:\\Users\\nws2293\\AppData\\Local\\Programs\\Python\\Python39\\lib",
"C:\\Users\\nws2293\\AppData\\Local\\Programs\\Python\\Python39",
"C:\\tmp\\tox_4.0.9_bug\\.tox\\default",
"C:\\tmp\\tox_4.0.9_bug\\.tox\\default\\lib\\site-packages"
],
"meta_path": [
"<class '_virtualenv._Finder'>",
"<class '_frozen_importlib.BuiltinImporter'>",
"<class '_frozen_importlib.FrozenImporter'>",
"<class '_frozen_importlib_external.PathFinder'>"
],
"fs_encoding": "utf-8",
"io_encoding": "cp1252"
},
"version": "3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]",
"makefile_filename": "C:\\Users\\nws2293\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\config\\Makefile",
"os": "<module 'os' from 'C:\\\\Users\\\\nws2293\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python39\\\\lib\\\\os.py'>",
"site": "<module 'site' from 'C:\\\\Users\\\\nws2293\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python39\\\\lib\\\\site.py'>",
"datetime": "<module 'datetime' from 'C:\\\\Users\\\\nws2293\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python39\\\\lib\\\\datetime.py'>",
"math": "<module 'math' (built-in)>",
"json": "<module 'json' from 'C:\\\\Users\\\\nws2293\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python39\\\\lib\\\\json\\\\__init__.py'>"
} [virtualenv\run\session.py:51]
default: 3034 I add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\nws2293\AppData\Local\pypa\virtualenv) [virtualenv\run\session.py:55]
default: 3051 D got embed update of distribution setuptools from C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\embed\3\setuptools.json [virtualenv\app_data\via_disk_folder.py:129]
default: 3052 D got embed update of distribution pip from C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\embed\3\pip.json [virtualenv\app_data\via_disk_folder.py:129]
default: 3053 D got embed update of distribution wheel from C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\embed\3\wheel.json [virtualenv\app_data\via_disk_folder.py:129]
default: 3060 D install setuptools from wheel C:\tmp\tox_4.0.9_bug\.venv\lib\site-packages\virtualenv\seed\wheels\embed\setuptools-65.6.3-py3-none-any.whl via CopyPipInstall [virtualenv\seed\embed\via_app_data\via_app_data.py:47]
default: 3062 D install pip from wheel C:\tmp\tox_4.0.9_bug\.venv\lib\site-packages\virtualenv\seed\wheels\embed\pip-22.3.1-py3-none-any.whl via CopyPipInstall [virtualenv\seed\embed\via_app_data\via_app_data.py:47]
default: 3063 D install wheel from wheel C:\tmp\tox_4.0.9_bug\.venv\lib\site-packages\virtualenv\seed\wheels\embed\wheel-0.38.4-py3-none-any.whl via CopyPipInstall [virtualenv\seed\embed\via_app_data\via_app_data.py:47]
default: 3077 D copy directory C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\pip-22.3.1-py3-none-any\pip to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\pip [virtualenv\util\path\_sync.py:36]
default: 3078 D copy C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\setuptools-65.6.3-py3-none-any\distutils-precedence.pth to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\distutils-precedence.pth [virtualenv\util\path\_sync.py:36]
default: 3080 D copy directory C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\wheel-0.38.4-py3-none-any\wheel to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\wheel [virtualenv\util\path\_sync.py:36]
default: 3094 D copy directory C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\setuptools-65.6.3-py3-none-any\pkg_resources to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\pkg_resources [virtualenv\util\path\_sync.py:36]
default: 3399 D copy directory C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\wheel-0.38.4-py3-none-any\wheel-0.38.4.dist-info to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\wheel-0.38.4.dist-info [virtualenv\util\path\_sync.py:36]
default: 3515 D copy C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\wheel-0.38.4-py3-none-any\wheel-0.38.4.virtualenv to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\wheel-0.38.4.virtualenv [virtualenv\util\path\_sync.py:36]
default: 3583 D generated console scripts wheel3.9.exe wheel-3.9.exe wheel3.exe wheel.exe [virtualenv\seed\embed\via_app_data\pip_install\base.py:41]
default: 3911 D copy directory C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\setuptools-65.6.3-py3-none-any\setuptools to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\setuptools [virtualenv\util\path\_sync.py:36]
default: 6578 D copy directory C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\setuptools-65.6.3-py3-none-any\setuptools-65.6.3.dist-info to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\setuptools-65.6.3.dist-info [virtualenv\util\path\_sync.py:36]
default: 6686 D copy C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\setuptools-65.6.3-py3-none-any\setuptools-65.6.3.virtualenv to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\setuptools-65.6.3.virtualenv [virtualenv\util\path\_sync.py:36]
default: 6693 D copy directory C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\setuptools-65.6.3-py3-none-any\_distutils_hack to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\_distutils_hack [virtualenv\util\path\_sync.py:36]
default: 6737 D generated console scripts [virtualenv\seed\embed\via_app_data\pip_install\base.py:41]
default: 10295 D copy directory C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\pip-22.3.1-py3-none-any\pip-22.3.1.dist-info to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\pip-22.3.1.dist-info [virtualenv\util\path\_sync.py:36]
default: 10382 D copy C:\Users\nws2293\AppData\Local\pypa\virtualenv\wheel\3.9\image\1\CopyPipInstall\pip-22.3.1-py3-none-any\pip-22.3.1.virtualenv to C:\tmp\tox_4.0.9_bug\.tox\default\Lib\site-packages\pip-22.3.1.virtualenv [virtualenv\util\path\_sync.py:36]
default: 10413 D generated console scripts pip.exe pip3.9.exe pip-3.9.exe pip3.exe [virtualenv\seed\embed\via_app_data\pip_install\base.py:41]
default: 10413 I add activators for Bash, Batch, Fish, Nushell, PowerShell, Python [virtualenv\run\session.py:61]
default: 10513 D write C:\tmp\tox_4.0.9_bug\.tox\default\pyvenv.cfg [virtualenv\create\pyenv_cfg.py:30]
default: 10513 D home = C:\Users\nws2293\AppData\Local\Programs\Python\Python39 [virtualenv\create\pyenv_cfg.py:34]
default: 10514 D implementation = CPython [virtualenv\create\pyenv_cfg.py:34]
default: 10514 D version_info = 3.9.10.final.0 [virtualenv\create\pyenv_cfg.py:34]
default: 10514 D virtualenv = 20.17.1 [virtualenv\create\pyenv_cfg.py:34]
default: 10515 D include-system-site-packages = false [virtualenv\create\pyenv_cfg.py:34]
default: 10515 D base-prefix = C:\Users\nws2293\AppData\Local\Programs\Python\Python39 [virtualenv\create\pyenv_cfg.py:34]
default: 10516 D base-exec-prefix = C:\Users\nws2293\AppData\Local\Programs\Python\Python39 [virtualenv\create\pyenv_cfg.py:34]
default: 10516 D base-executable = C:\Users\nws2293\AppData\Local\Programs\Python\Python39\python.exe [virtualenv\create\pyenv_cfg.py:34]
default: 10534 W commands[0]> pytest [tox\tox_env\api.py:417]
default: 10713 E failed with pytest is not allowed, use allowlist_externals to allow it [tox\session\cmd\run\single.py:54]
default: FAIL code 1 (8.64 seconds)
evaluation failed :( (9.83 seconds)
This is a stripped down tox.ini file, "C:\tmp\tox_4.0.9_bug\tox.ini".
If I run "tox -e docs" with tox 4.0.9, this is the output. Notice that the substitution of {env:BUILD} works in the first part of the line but not in the second part following the {/}:
(.venv) C:\tmp\tox_4.0.9_bug>tox -e docs
docs: commands[0]> python -c "print(\"html -- C:\tmp\tox_4.0.9_bug\docs\_build{env:BUILD}\")"
html -- C: mp ox_4.0.9_bug\docs\_build{env:BUILD}
docs: OK (5.73=setup[5.16]+cmd[0.58] seconds)
congratulations :) (6.73 seconds)
C:\tmp\tox_4.0.9_bug>tox -e docs
docs run-test-pre: PYTHONHASHSEED='297'
docs run-test: commands[0] | python -c 'print("html -- C:\tmp\tox_4.0.9_bug\docs\_build\html")'
html -- C: mp ox_4.0.9_bug\docs\_build\html
docs: commands succeeded
congratulations :)
Issue
All of our build pipelines are failing due to what appears to be a bug with environment variable substitution in our tox.ini. The variable substitution works as expected with tox==3.27.1, but we start having issues with tox==4.0.9.
Environment
Provide at least:
pip listof the host Python wheretoxis installed:Output of running tox
Provide the output of
tox -rvv:Minimal example
This is a stripped down tox.ini file, "C:\tmp\tox_4.0.9_bug\tox.ini".
If I run "tox -e docs" with tox 4.0.9, this is the output. Notice that the substitution of
{env:BUILD}works in the first part of the line but not in the second part following the{/}:If I run "tox -e docs" with tox 3.27.1, this is the output: