tox
tox copied to clipboard
Unable to modify PATH environment variable by setenv
Issue
When try to append path to PATH environment variable via setenv section in tox.ini, it will not take effect.
setenv =
PATH = {env:PATH}:/test
commands =
env
As above tox.ini example, I can't find append /test in command env output.
Environment
- OS: Ubuntu 22.04.3 LTS
- Python: 3.10.12
Output of pip list of the host Python, where tox is installed
Package Version
----------------- -------
cachetools 5.5.0
chardet 5.2.0
colorama 0.4.6
distlib 0.3.9
filelock 3.16.1
packaging 24.2
pip 22.0.2
platformdirs 4.3.6
pluggy 1.5.0
pyproject-api 1.8.0
setuptools 59.6.0
tomli 2.1.0
tox 4.23.2
typing_extensions 4.12.2
virtualenv 20.27.1
Output of running tox
Output of tox -rvv
❯ python3 -m tox run -rvv -e test
test: 201 W remove tox env folder /home/username/.tox/test [tox/tox_env/api.py:325]
test: 238 I find interpreter for spec PythonSpec(path=/home/username/.venv/bin/python3) [virtualenv/discovery/builtin.py:73]
test: 239 D filesystem is case-sensitive [virtualenv/info.py:25]
test: 239 D discover exe for PythonInfo(spec=CPython3.10.12.final.0-64, exe=/home/username/.venv/bin/python3, platform=linux, version='3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0]', encoding_fs_io=utf-8-utf-8) in /usr [virtualenv/discovery/py_info.py:437]
test: 240 D got python info of %s from (PosixPath('/usr/bin/python3.10'), PosixPath('/home/username/.local/share/virtualenv/py_info/1/8a94588eda9d64d9e9a351ab8144e55b1fabf5113b54e67dd26a8c27df0381b3.json')) [virtualenv/app_data/via_disk_folder.py:131]
test: 241 I proposed PythonInfo(spec=CPython3.10.12.final.0-64, system=/usr/bin/python3.10, exe=/home/username/.venv/bin/python3, platform=linux, version='3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:80]
test: 241 D accepted PythonInfo(spec=CPython3.10.12.final.0-64, system=/usr/bin/python3.10, exe=/home/username/.venv/bin/python3, platform=linux, version='3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:82]
test: 275 I create virtual environment via CPython3Posix(dest=/home/username/.tox/test, clear=False, no_vcs_ignore=False, global=False) [virtualenv/run/session.py:50]
test: 275 D create folder /home/username/.tox/test/bin [virtualenv/util/path/_sync.py:12]
test: 275 D create folder /home/username/.tox/test/lib/python3.10/site-packages [virtualenv/util/path/_sync.py:12]
test: 276 D write /home/username/.tox/test/pyvenv.cfg [virtualenv/create/pyenv_cfg.py:33]
test: 276 D home = /usr/bin [virtualenv/create/pyenv_cfg.py:38]
test: 276 D implementation = CPython [virtualenv/create/pyenv_cfg.py:38]
test: 276 D version_info = 3.10.12.final.0 [virtualenv/create/pyenv_cfg.py:38]
test: 276 D virtualenv = 20.27.1 [virtualenv/create/pyenv_cfg.py:38]
test: 276 D include-system-site-packages = false [virtualenv/create/pyenv_cfg.py:38]
test: 276 D base-prefix = /usr [virtualenv/create/pyenv_cfg.py:38]
test: 276 D base-exec-prefix = /usr [virtualenv/create/pyenv_cfg.py:38]
test: 276 D base-executable = /usr/bin/python3.10 [virtualenv/create/pyenv_cfg.py:38]
test: 277 D symlink /usr/bin/python3.10 to /home/username/.tox/test/bin/python [virtualenv/util/path/_sync.py:32]
test: 277 D create virtualenv import hook file /home/username/.tox/test/lib/python3.10/site-packages/_virtualenv.pth [virtualenv/create/via_global_ref/api.py:91]
test: 277 D create /home/username/.tox/test/lib/python3.10/site-packages/_virtualenv.py [virtualenv/create/via_global_ref/api.py:94]
test: 278 D ============================== target debug ============================== [virtualenv/run/session.py:52]
test: 278 D debug via /home/username/.tox/test/bin/python /home/username/.venv/lib/python3.10/site-packages/virtualenv/create/debug.py [virtualenv/create/creator.py:200]
test: 278 D {
"sys": {
"executable": "/home/username/.tox/test/bin/python",
"_base_executable": "/home/username/.tox/test/bin/python",
"prefix": "/home/username/.tox/test",
"base_prefix": "/usr",
"real_prefix": null,
"exec_prefix": "/home/username/.tox/test",
"base_exec_prefix": "/usr",
"path": [
"/usr/lib/python310.zip",
"/usr/lib/python3.10",
"/usr/lib/python3.10/lib-dynload",
"/home/username/.tox/test/lib/python3.10/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": "utf-8"
},
"version": "3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0]",
"makefile_filename": "/usr/lib/python3.10/config-3.10-x86_64-linux-gnu/Makefile",
"os": "<module 'os' from '/usr/lib/python3.10/os.py'>",
"site": "<module 'site' from '/usr/lib/python3.10/site.py'>",
"datetime": "<module 'datetime' from '/usr/lib/python3.10/datetime.py'>",
"math": "<module 'math' (built-in)>",
"json": "<module 'json' from '/usr/lib/python3.10/json/__init__.py'>"
} [virtualenv/run/session.py:53]
test: 311 I add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/username/.local/share/virtualenv) [virtualenv/run/session.py:57]
test: 314 D got embed update of distribution %s from ('setuptools', PosixPath('/home/username/.local/share/virtualenv/wheel/3.10/embed/3/setuptools.json')) [virtualenv/app_data/via_disk_folder.py:131]
test: 315 D got embed update of distribution %s from ('wheel', PosixPath('/home/username/.local/share/virtualenv/wheel/3.10/embed/3/wheel.json')) [virtualenv/app_data/via_disk_folder.py:131]
test: 316 D got embed update of distribution %s from ('pip', PosixPath('/home/username/.local/share/virtualenv/wheel/3.10/embed/3/pip.json')) [virtualenv/app_data/via_disk_folder.py:131]
test: 318 D using periodically updated wheel /home/username/.local/share/virtualenv/wheel/house/wheel-0.41.3-py3-none-any.whl [virtualenv/seed/wheels/periodic_update.py:48]
test: 318 D using periodically updated wheel /home/username/.local/share/virtualenv/wheel/house/setuptools-68.2.2-py3-none-any.whl [virtualenv/seed/wheels/periodic_update.py:48]
test: 319 D using periodically updated wheel /home/username/.local/share/virtualenv/wheel/house/pip-24.0-py3-none-any.whl [virtualenv/seed/wheels/periodic_update.py:48]
test: 319 D install wheel from wheel /home/username/.local/share/virtualenv/wheel/house/wheel-0.41.3-py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:49]
test: 320 D install setuptools from wheel /home/username/.local/share/virtualenv/wheel/house/setuptools-68.2.2-py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:49]
test: 320 D install pip from wheel /home/username/.local/share/virtualenv/wheel/house/pip-24.0-py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:49]
test: 323 D copy directory /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-24.0-py3-none-any/pip-24.0.dist-info to /home/username/.tox/test/lib/python3.10/site-packages/pip-24.0.dist-info [virtualenv/util/path/_sync.py:40]
test: 323 D copy directory /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.41.3-py3-none-any/wheel-0.41.3.dist-info to /home/username/.tox/test/lib/python3.10/site-packages/wheel-0.41.3.dist-info [virtualenv/util/path/_sync.py:40]
test: 323 D copy directory /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-68.2.2-py3-none-any/setuptools-68.2.2.dist-info to /home/username/.tox/test/lib/python3.10/site-packages/setuptools-68.2.2.dist-info [virtualenv/util/path/_sync.py:40]
test: 327 D copy directory /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.41.3-py3-none-any/wheel to /home/username/.tox/test/lib/python3.10/site-packages/wheel [virtualenv/util/path/_sync.py:40]
test: 327 D copy /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-68.2.2-py3-none-any/setuptools-68.2.2.virtualenv to /home/username/.tox/test/lib/python3.10/site-packages/setuptools-68.2.2.virtualenv [virtualenv/util/path/_sync.py:40]
test: 328 D copy /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-24.0-py3-none-any/pip-24.0.virtualenv to /home/username/.tox/test/lib/python3.10/site-packages/pip-24.0.virtualenv [virtualenv/util/path/_sync.py:40]
test: 328 D copy directory /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-68.2.2-py3-none-any/setuptools to /home/username/.tox/test/lib/python3.10/site-packages/setuptools [virtualenv/util/path/_sync.py:40]
test: 329 D copy directory /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-24.0-py3-none-any/pip to /home/username/.tox/test/lib/python3.10/site-packages/pip [virtualenv/util/path/_sync.py:40]
test: 340 D copy /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.41.3-py3-none-any/wheel-0.41.3.virtualenv to /home/username/.tox/test/lib/python3.10/site-packages/wheel-0.41.3.virtualenv [virtualenv/util/path/_sync.py:40]
test: 343 D generated console scripts wheel3 wheel wheel3.10 wheel-3.10 [virtualenv/seed/embed/via_app_data/pip_install/base.py:43]
test: 382 D copy /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-68.2.2-py3-none-any/distutils-precedence.pth to /home/username/.tox/test/lib/python3.10/site-packages/distutils-precedence.pth [virtualenv/util/path/_sync.py:40]
test: 382 D copy directory /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-68.2.2-py3-none-any/_distutils_hack to /home/username/.tox/test/lib/python3.10/site-packages/_distutils_hack [virtualenv/util/path/_sync.py:40]
test: 383 D copy directory /home/username/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-68.2.2-py3-none-any/pkg_resources to /home/username/.tox/test/lib/python3.10/site-packages/pkg_resources [virtualenv/util/path/_sync.py:40]
test: 396 D generated console scripts [virtualenv/seed/embed/via_app_data/pip_install/base.py:43]
test: 435 D generated console scripts pip3.10 pip3 pip pip-3.10 [virtualenv/seed/embed/via_app_data/pip_install/base.py:43]
test: 436 I add activators for Bash, CShell, Fish, Nushell, PowerShell, Python [virtualenv/run/session.py:63]
test: 438 D write /home/username/.tox/test/pyvenv.cfg [virtualenv/create/pyenv_cfg.py:33]
test: 439 D home = /usr/bin [virtualenv/create/pyenv_cfg.py:38]
test: 439 D implementation = CPython [virtualenv/create/pyenv_cfg.py:38]
test: 439 D version_info = 3.10.12.final.0 [virtualenv/create/pyenv_cfg.py:38]
test: 439 D virtualenv = 20.27.1 [virtualenv/create/pyenv_cfg.py:38]
test: 439 D include-system-site-packages = false [virtualenv/create/pyenv_cfg.py:38]
test: 439 D base-prefix = /usr [virtualenv/create/pyenv_cfg.py:38]
test: 439 D base-exec-prefix = /usr [virtualenv/create/pyenv_cfg.py:38]
test: 439 D base-executable = /usr/bin/python3.10 [virtualenv/create/pyenv_cfg.py:38]
test: 441 W commands[0]> env [tox/tox_env/api.py:427]
HOME=/home/username
TERM=xterm-256color
LANG=en_US.UTF-8
PATH=/home/username/.tox/test/bin:/home/username/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PYTHONHASHSEED=1573952959
PIP_DISABLE_PIP_VERSION_CHECK=1
PYTHONIOENCODING=utf-8
TOX_ENV_NAME=test
TOX_WORK_DIR=/home/username/.tox
TOX_ENV_DIR=/home/username/.tox/test
VIRTUAL_ENV=/home/username/.tox/test
COLUMNS=208
LINES=44
test: 446 I exit 0 (0.00 seconds) /home/username> env pid=3704561 [tox/execute/api.py:286]
test: OK (0.25=setup[0.24]+cmd[0.00] seconds)
congratulations :) (0.31 seconds)
Minimal example
[testenv:test]
skip_install = true
allowlist_externals = env
setenv =
PATH = {env:PATH}:/test
commands =
env
Analysis
Issue seems caused by line 370~373 in src/tox/tox_env/api.py. _paths.setter should not modify self._env_vars directly. Remove these lines issue fixed.