Skip to content

🐛 fix(cli): make multiple -e flags additive#3755

Merged
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:fix-multiple-e-additive-3199
Feb 18, 2026
Merged

🐛 fix(cli): make multiple -e flags additive#3755
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:fix-multiple-e-additive-3199

Conversation

@gaborbernat
Copy link
Copy Markdown
Member

In tox 3, running tox -e a -e b would execute both environments. In tox 4 the second -e silently replaced the first, so only b would run. 🔍 This broke CI pipelines and scripts that relied on the additive behavior, with no error or warning to indicate environments were being dropped.

The fix uses a custom argparse action that accumulates values from repeated -e flags into a single CliEnv instance instead of replacing it. This restores tox 3 behavior while preserving full backward compatibility — tox -e a,b (comma-separated) continues to work exactly as before.

⚠️ Users who were relying on later -e flags to override earlier ones will now get the union of all specified environments. The comma-separated form tox -e a,b remains the canonical way to specify multiple environments in a single flag.

Fixes #3199

@gaborbernat gaborbernat added the bug:normal affects many people or has quite an impact label Feb 18, 2026
@gaborbernat gaborbernat enabled auto-merge (squash) February 18, 2026 14:19
@gaborbernat gaborbernat force-pushed the fix-multiple-e-additive-3199 branch 2 times, most recently from cf5f28a to 44733aa Compare February 18, 2026 14:24
In tox 3, `tox -e a -e b` would run both environments. In tox 4
the second `-e` silently replaced the first, running only `b`. This
broke CI pipelines that relied on the additive behavior.

Replaced the default argparse store action with a custom action that
accumulates values into the existing CliEnv via a new `__iadd__`
method, so repeated `-e` flags merge their environment lists.

Fixes tox-dev#3199
@gaborbernat gaborbernat force-pushed the fix-multiple-e-additive-3199 branch from 44733aa to ad7e4ad Compare February 18, 2026 14:34
@gaborbernat gaborbernat merged commit 47ec87f into tox-dev:main Feb 18, 2026
28 checks passed
@gaborbernat gaborbernat deleted the fix-multiple-e-additive-3199 branch February 18, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided bug:normal affects many people or has quite an impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple -e options behave differently in tox 4.x vs tox 3.x

1 participant