tox: posargs with `:` crashes virtualenv

Issue

posargs with : are not properly passed, virtualenv crashes.

Environment

Provide at least:

  • OS: Ubuntu 20.04
  • pip list of the host Python where tox is installed:
Package               Version
--------------------- ---------
anyio                 3.6.2
artifacts-keyring     0.3.2
attrs                 22.2.0
bleach                5.0.1
cachetools            5.2.1
certifi               2022.12.7
cffi                  1.15.1
chardet               5.1.0
charset-normalizer    2.1.1
click                 8.1.3
colorama              0.4.6
commonmark            0.9.1
cryptography          39.0.0
distlib               0.3.6
docutils              0.19
exceptiongroup        1.1.0
filelock              3.9.0
h11                   0.14.0
html5lib              1.1
httpcore              0.16.3
httpx                 0.23.3
idna                  3.4
importlib-metadata    6.0.0
importlib-resources   5.10.2
iniconfig             2.0.0
jaraco.classes        3.2.3
jeepney               0.8.0
keyring               23.13.1
more-itertools        9.0.0
packaging             23.0
pip                   22.3.1
pkginfo               1.9.6
platformdirs          2.6.2
pluggy                1.0.0
pycparser             2.21
pydantic              1.10.4
Pygments              2.14.0
pyproject_api         1.4.0
pytest                7.2.0
pytest-httpx          0.21.2
readme-renderer       37.3
requests              2.28.1
requests-toolbelt     0.10.1
rfc3986               1.5.0
rich                  13.0.1
SecretStorage         3.3.3
setuptools            57.5.0
simpleindex           0.5.0
simpleindex_artifacts 0.3
six                   1.16.0
sniffio               1.3.0
starlette             0.23.1
toml                  0.10.2
tomli                 2.0.1
tox                   4.2.8
twine                 4.0.2
typing_extensions     4.4.0
urllib3               1.26.14
uvicorn               0.20.0
virtualenv            20.17.1
webencodings          0.5.1
wheel                 0.38.4
zipp                  3.11.0

Output of running tox

Provide the output of tox -rvv:

ROOT: 89 D setup logging to DEBUG on pid 26084 [tox/report.py:221]
.pkg: 156 I find interpreter for spec PythonSpec(path=/usr/local/bin/python) [virtualenv/discovery/builtin.py:56]
.pkg: 156 I proposed PythonInfo(spec=CPython3.8.16.final.0-64, exe=/usr/local/bin/python, platform=linux, version='3.8.16 (default, Dec  8 2022, 03:18:29) \n[GCC 10.2.1 20210110]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:63]
.pkg: 156 D accepted PythonInfo(spec=CPython3.8.16.final.0-64, exe=/usr/local/bin/python, platform=linux, version='3.8.16 (default, Dec  8 2022, 03:18:29) \n[GCC 10.2.1 20210110]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:65]
.pkg: 158 D filesystem is case-sensitive [virtualenv/info.py:24]
.pkg: 180 I find interpreter for spec PythonSpec(path=/usr/local/bin/python) [virtualenv/discovery/builtin.py:56]
.pkg: 180 I proposed PythonInfo(spec=CPython3.8.16.final.0-64, exe=/usr/local/bin/python, platform=linux, version='3.8.16 (default, Dec  8 2022, 03:18:29) \n[GCC 10.2.1 20210110]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:63]
.pkg: 181 D accepted PythonInfo(spec=CPython3.8.16.final.0-64, exe=/usr/local/bin/python, platform=linux, version='3.8.16 (default, Dec  8 2022, 03:18:29) \n[GCC 10.2.1 20210110]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:65]
.pkg: 184 I find interpreter for spec PythonSpec(path=/usr/local/bin/python) [virtualenv/discovery/builtin.py:56]
.pkg: 185 I proposed PythonInfo(spec=CPython3.8.16.final.0-64, exe=/usr/local/bin/python, platform=linux, version='3.8.16 (default, Dec  8 2022, 03:18:29) \n[GCC 10.2.1 20210110]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:63]
.pkg: 185 D accepted PythonInfo(spec=CPython3.8.16.final.0-64, exe=/usr/local/bin/python, platform=linux, version='3.8.16 (default, Dec  8 2022, 03:18:29) \n[GCC 10.2.1 20210110]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:65]
.pkg: 189 I find interpreter for spec PythonSpec(path=/usr/local/bin/python) [virtualenv/discovery/builtin.py:56]
.pkg: 190 I proposed PythonInfo(spec=CPython3.8.16.final.0-64, exe=/usr/local/bin/python, platform=linux, version='3.8.16 (default, Dec  8 2022, 03:18:29) \n[GCC 10.2.1 20210110]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:63]
.pkg: 190 D accepted PythonInfo(spec=CPython3.8.16.final.0-64, exe=/usr/local/bin/python, platform=linux, version='3.8.16 (default, Dec  8 2022, 03:18:29) \n[GCC 10.2.1 20210110]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:65]
.pkg: 204 I find interpreter for spec PythonSpec(path=/usr/local/bin/python) [virtualenv/discovery/builtin.py:56]
.pkg: 204 I proposed PythonInfo(spec=CPython3.8.16.final.0-64, exe=/usr/local/bin/python, platform=linux, version='3.8.16 (default, Dec  8 2022, 03:18:29) \n[GCC 10.2.1 20210110]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:63]
.pkg: 205 D accepted PythonInfo(spec=CPython3.8.16.final.0-64, exe=/usr/local/bin/python, platform=linux, version='3.8.16 (default, Dec  8 2022, 03:18:29) \n[GCC 10.2.1 20210110]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:65]
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--read-only-app-data] [--app-data APP_DATA] [--reset-app-data] [--upgrade-embed-wheels] [--discovery {builtin}] [-p py] [--try-first-with py_exe]
                  [--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed] [--activators comma_sep_list] [--clear] [--no-vcs-ignore] [--system-site-packages] [--symlinks | --copies] [--no-download | --download]
                  [--extra-search-dir d [d ...]] [--pip version] [--setuptools version] [--wheel version] [--no-pip] [--no-setuptools] [--no-wheel] [--no-periodic-update] [--symlink-app-data] [--prompt prompt] [-h]
                  dest
virtualenv: error: argument dest: destination '--junitxml=unit_tests_results.xml --cov=autoavatar --cov-report=xml:coverage.xml' must not contain the path separator (:) as this would break the activation scripts

Minimal example

If possible, provide a minimal reproducer for the issue:

UPDATE After doing the investigation, it turned out that one environment influences the other. Here is a minimum tox.ini to reproduce the issue: tox.int:

[tox]
minversion = 4.3.1

[testenv:hello]
commands =
    python ./helloworld.py {posargs:World}

[testenv:dev]
envdir = {posargs:venv}
usedevelop = True
commands =
    python ./helloworld.py World

tox -e hello -- x:y

...
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--read-only-app-data] [--app-data APP_DATA] [--reset-app-data] [--upgrade-embed-wheels] [--discovery {builtin}] [-p py] [--try-first-with py_exe]
                  [--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed] [--activators comma_sep_list] [--clear] [--no-vcs-ignore] [--system-site-packages] [--symlinks | --copies] [--no-download | --download]
                  [--extra-search-dir d [d ...]] [--pip version] [--setuptools version] [--wheel version] [--no-pip] [--no-setuptools] [--no-wheel] [--no-periodic-update] [--symlink-app-data] [--prompt prompt] [-h]
                  dest
virtualenv: error: argument dest: destination 'x:y' must not contain the path separator (:) as this would break the activation scripts

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 25 (23 by maintainers)

Most upvoted comments

One thing we could do here is to move the configuration error raised by virtualenv to a runtime error. A PR in that direction would be accepted.

I do agree that passing posargs for all environments is okay if no environment is selected with - e. But it not really expected when a specific environment is selected

We’ll need to agree to disagree on this. The configuration does not change depending on active or inactive state of an env. That would be confusing. If for some envs the posargs does not make sense do not call it.

Happy to give it a try next week if that is okay.