Skip to content

tox4: Unable to run env called run #2728

@sdatko

Description

@sdatko

Issue

I have tox environment called run I use to run some commands inside virtual environment where my project is installed (i.e. conveniently testing CLI of the development builds) and since tox version 4.0 it fails with error.

As I can see, there were subcommands now introduced to tox – and apparently the run is being intercepted from the -e. This is not the correct behavior.

Environment

Provide at least:

  • OS: Arch Linux (up to date)
  • 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.2.2
platformdirs  2.6.0
pluggy        1.0.0
pyproject_api 1.2.1
setuptools    63.2.0
tomli         2.0.1
tox           4.0.11
virtualenv    20.17.1

Output of running tox

[sdatko@polluks tox]$ tox3 -e run -- echo 'I am in venv'
run recreate: /home/sdatko/Development/tox/.tox/run
run run-test-pre: PYTHONHASHSEED='350351148'
run run-test: commands[0] | echo 'I am in venv'
I am in venv
__________________ summary __________________
  run: commands succeeded
  congratulations :)
[sdatko@polluks tox]$ tox3 -e other -- echo 'I am in venv'
other create: /home/sdatko/Development/tox/.tox/other
other run-test-pre: PYTHONHASHSEED='1845399330'
other run-test: commands[0] | echo 'I am in venv'
I am in venv
__________________ summary __________________
  other: commands succeeded
  congratulations :)
[sdatko@polluks tox]$ tox4 -e run -- echo 'I am in venv'
usage: tox run [-h] [--colored {yes,no}] [--exit-and-dump-after seconds] [-c file] [--workdir dir] [--root dir] [--runner {virtualenv}] [-v | -q] [-e ENV | -m label [label ...] | -f factor [factor ...] | --skip-env re] [--result-json path]
               [-s [v]] [-n] [-b] [--installpkg INSTALL_PKG] [--develop] [--hashseed SEED] [--discover path [path ...]] [--no-recreate-pkg] [--skip-pkg-install] [--version] [--no-provision [REQ_JSON]] [--no-recreate-provision] [-r]
               [-x OVERRIDE]
tox run: error: argument -e: expected one argument
[sdatko@polluks tox]$ tox4 -e other -- echo 'I am in venv'
other: commands[0]> echo 'I am in venv'
I am in venv
  other: OK (0.13=setup[0.13]+cmd[0.00] seconds)
  congratulations :) (0.23 seconds)

Minimal example

If possible, provide a minimal reproducer for the issue:

The tox.ini file:

[tox]
env_list = py310
skipsdist = True

[testenv]
allowlist_externals = echo
commands = echo default

[testenv:run]
commands = {posargs}

[testenv:other]
commands = {posargs}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:documentationhelp:wantedIssues that have been acknowledged, a solution determined and a PR might likely be accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions