tox icon indicating copy to clipboard operation
tox copied to clipboard

Using requires may disable plugins

Open ziima opened this issue 2 years ago • 0 comments

We discovered an unexpected error with tox plugins. Using both installed plugins and requires keyword may cause local plugins to be disabled. When requires is used and it contains a tox plugin (or tox or anything else which installs tox) internally that tox in runned later on and as a consequence it doesn't contain locally installed plugins. This seems to be a bug, since tox itself confirms local plugins are active.

Also I should mention that using both is legitimate, since requires specifies plugins related to the project itself whereas local plugins can be used to the developers environment/habits/tools etc.

Example

Have tox with tox-ipdb-plugin installed (it installs ipdb to all tox envs - handy for debugging) and tox.ini as follows:

[tox]
requires =
    tox-envlist

[testenv]
commands =
    python -c "import ipdb; print(ipdb)"

Then the run will fail with

.tox create: /tmp/tox-pokus/.tox/.tox
.tox installdeps: tox-envlist, tox >= 3.23.0
py310 create: /tmp/tox-pokus/.tox/py310
py310 run-test-pre: PYTHONHASHSEED='4146503376'
py310 run-test: commands[0] | python -c 'import ipdb; print(ipdb)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'ipdb'
ERROR: InvocationError for command /tmp/tox-pokus/.tox/py310/bin/python -c 'import ipdb; print(ipdb)' (exited with code 1)
________________________________________________________________________________________________ summary _________________________________________________________________________________________________
ERROR:   py310: commands failed

The tox --version confirms I have tox-ipdb-plugin installed

3.23.0 imported from /home/vzima/.local/lib/python3.9/site-packages/tox/__init__.py
registered plugins:
    tox-ipdb-plugin-0.1 at /home/vzima/.local/lib/python3.9/site-packages/tox_ipdb.py

(Tested on several versions of tox)

It works fine if I delete the tox-envlist from requires.

I'm not quite sure, how the solution should work, but in any case local plugins should keep working.

ziima avatar Jul 26 '22 12:07 ziima