Skip to content

Bug candidate: incorrect cache invalidation scheme #3917

Closed

Description

@neutrinoceros

Maybe this is working as expected, but it looks like a bug to me: I'm trying to set up a project with tox-uv such that

  • unless explicitly specified via an env var, uv ignores packages released after a given date (here, specified as absolute for reproducibility)
  • some env factors do allow latest versions of everything

Here's the setup
pyproject.toml

[project]
name = "test"
version = "0.1.0"
requires-python = ">=3.14"
dependencies = [
    # inifix is a tiny, 0-deps package of mine.
    # 6.1.1: 2025-04-14 
    # 6.1.2: 2026-04-01
    "inifix>=6.1.1",
]

[tool.uv]
exclude-newer = "2026-03-01" # should exclude inifix 6.1.1

tox.ini

[tox]
envlist =
    py314,-pre
requires =
    tox-uv

[testenv]
setenv =
    pre: UV_EXCLUDE_NEWER = 0day # allow latest versions
commands =
    {list_dependencies_command}

If I run uvx tox -e py314-pre without a cache, this works as expected (I get inifix==6.1.2). I'll call this the baseline run.
However, if I follow the following steps

rm -fr .tox || true
# comment out `setenv` settings from tox.ini
uvx tox -e py314-pre
# uncomment the setting
uvx tox -e py314-pre

Then I get inifix==6.1.1 on both run. It is the correct result for the first run, but not the second: the only difference between the second run here and the baseline run is the state of tox's chache, and it's causing results to differ. My conclusion is that the cache was erroneously validated when it shouldn't have; of course it's impractical for tox to guess exactly what changes should invalidate the cache, but I would expect one of the following:

  1. any change to tox.ini should invalidate the cache

  2. if tox tries to be smart about it, tox-uv should be able to extend the rules to invalidate any change in a UV_-prefixed env var.

  3. users should be able to customize cache keys in some way

  4. would be my preference
    I don't know how close 2) is from the current state of affairs (I couldn't locate the logic in tox's code), but depending on the situation it might be a bug in tox, in tox-uv, or both.

  5. is by far my least favorite option, because it doesn't resolve the core issue that the default behavior is incorrect.

Activity

  1. added 2 commits that reference this issue on Apr 9, 2026
    186e2c7
    f2f86df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions