Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Count a RECORD path claim before the row is filtered out (#8181)

Lee Jackson5f5f1e355084
diff --git a/studio/backend/utils/transformers_version.py b/studio/backend/utils/transformers_version.py
index e0fd6d2b5f5..7e10f03387d 100644
--- a/studio/backend/utils/transformers_version.py
+++ b/studio/backend/utils/transformers_version.py
@@ -2095,6 +2095,10 @@ def _sidecar_scan_impl(venv_dir: str, limit: int = 3) -> tuple[list[str], bool]:
or (parts and parts[0] in ("bin", "Scripts"))
):
continue
+ target = root / rel
+ key = os.path.normcase(str(target))
+ # Before the filter: a dropped row still owns the path it claims.
+ owners[key] = owners.get(key, 0) + 1
# Top-level dirs several wheels write into, so one uninstall deletes
# another's files. Unreliable ownership is a property of the path, so
# this covers what we ship too; see _shared_non_runtime in _studio_deps.
@@ -2110,9 +2114,6 @@ def _sidecar_scan_impl(venv_dir: str, limit: int = 3) -> tuple[list[str], bool]:
recorded = int(row[2])
except ValueError:
recorded = None
- target = root / rel
- key = os.path.normcase(str(target))
- owners[key] = owners.get(key, 0) + 1
entries.append((name, rel, recorded, target, key))
found: list[str] = []
diff --git a/unsloth_cli/_studio_deps.py b/unsloth_cli/_studio_deps.py
index 9385a6951f0..186dd7f74bf 100644
--- a/unsloth_cli/_studio_deps.py
+++ b/unsloth_cli/_studio_deps.py
@@ -255,7 +255,9 @@ def _shared_non_runtime(rel: str) -> bool:
with `unsloth_zoo: tests/conftest.py is 8107 bytes, expected 11429`. Our
runtime trees are unaffected, since none of them is named for a shared root.
Applied while reading RECORD, not when reporting, so the row also stays out
- of the ownership tally and the `limit` budget.
+ of the `limit` budget. Its claim is still counted: dropping a colliding row
+ before the tally is what made a retained row look singly owned, so another
+ distribution's file got measured against unsloth_zoo's RECORD.
"""
parts = tuple(p for p in rel.replace("\\", "/").split("/") if p and p != ".")
return len(parts) > 1 and parts[0] in _SHARED_NON_RUNTIME_ROOTS
@@ -331,6 +333,13 @@ def damaged_installed_files(limit: int = 8) -> List[str]:
# size recorded inside itself; .pyc is regenerated from source.
if ".dist-info/" in rel or ".egg-info/" in rel or rel.endswith(".pyc"):
continue
+ try:
+ target = dist.locate_file(rel)
+ except Exception:
+ continue
+ key = os.path.normcase(str(target))
+ # Before the filter: a dropped row still owns the path it claims.
+ owners[key] = owners.get(key, 0) + 1
if _shared_non_runtime(rel):
continue
# The size field is optional and real wheels do leave it blank. Keep
@@ -342,12 +351,6 @@ def damaged_installed_files(limit: int = 8) -> List[str]:
recorded = int(row[2])
except ValueError:
recorded = None
- try:
- target = dist.locate_file(rel)
- except Exception:
- continue
- key = os.path.normcase(str(target))
- owners[key] = owners.get(key, 0) + 1
entries.append((name, rel, recorded, target, key))
found: List[str] = []
diff --git a/unsloth_cli/tests/test_studio_update_verify.py b/unsloth_cli/tests/test_studio_update_verify.py
index 68f88c0d749..a6953c614b2 100644
--- a/unsloth_cli/tests/test_studio_update_verify.py
+++ b/unsloth_cli/tests/test_studio_update_verify.py
@@ -705,6 +705,19 @@ def test_our_own_shared_top_level_trees_are_exempt_too(site):
assert _deps().damaged_installed_files() == []
+def test_two_distributions_claiming_one_shared_path(site):
+ # The real shape: a third party also ships tests/conftest.py and lands last,
+ # so the bytes on disk match its RECORD and are shorter than unsloth_zoo's.
+ # Neither the drift nor the deletion can affect startup.
+ rel = "tests/conftest.py"
+ _make_dist(site, "unsloth_zoo", {rel: b"u" * 11429})
+ _make_dist(site, "upsilon", {rel: b"c" * 8107})
+ assert (site / rel).stat().st_size == 8107
+ assert _deps().damaged_installed_files() == []
+ (site / rel).unlink()
+ assert _deps().damaged_installed_files() == []
+
+
def test_our_own_shared_top_level_trees_may_also_vanish(site):
# Same path, deleted rather than overwritten: the einx shape, but claimed by
# a distribution of ours. No reinstall repairs it either.