nox: [BUG] --no-reuse-existing-virtualenvs doesn't seem to work
Describe the bug
Adding --no-reuse-existing-virtualenvs
does not seem to ignore the cache, and instead just reuses the existing environments anyway. Happened on the previous version, and then did a brew upgrade
, and 2021.10.1 also has this problem. Unless I misunderstand this option, pretty sure it’s broken.
How to reproduce
@nox.session(reuse_venv=True)
def type(session):
session.install('mypy')
session.run('mypy')
(simplified slightly, should be unimportant)
$ nox --no-reuse-existing-virtualenvs -s type
nox > Running session type
nox > Re-using existing virtual environment at .nox/type.
Expected behavior The existing virtual environment should not have been reused. (It really was, not just visually; I was trying to remove an item from the install list, but it remained installed).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 18 (2 by maintainers)
Alright, I think I understand what you’re getting at:
True
will be reused - this is the default behavior and matches the intended current behavior.--reuse
(True
) reuses envs for all sessions except ones markedFalse
. This matches the intended current behavior (that isn’t working correctly).--reuse=always
forces every session to re-use its env, and is not a valid option for local specification.--reuse=never
forces every session to re-create its env, and is not a valid option for local specification.If that’s the case, that works for me.
Hmm… Ideally we’d do the following (but it’s more work):
nox.options
setting from the noxfile, if it’s not None.So this would split your
True/False
row in two cases, depending on where the global setting comes from.Consider this noxfile:
I’d be surprised if the
test
session was not reused.On the other hand, I’d expect
nox --no-reuse-existing-virtualenvs --session test
to disable reuse.This behavior is definitely ambiguous if we’re just using True/False. What do y’all think using “yes”, “no”, “always” and “never”?
So:
--reuse=yes
reuses envs for all sessions except ones marked “never”.--reuse=no
(or unset) only reuses sessions marked “always”.--reuse=always
forces every session to re-use its env.--reuse=never
forces every session to re-create its env.The
noxfile.py
optionnox.options.reuse_existing_virtualenvs
should behave the same as the othernoxfile.py
options - it provides a default for the command-line arg if it isn’t specified.