Skip to content

The agent that grows with you

fix(pm): spell store roots PM opens without Store like Store does

alt-glitcha1461d11abb0
diff --git a/pm/_uv.py b/pm/_uv.py
index 76ba629c6dd..b70477463e6 100644
--- a/pm/_uv.py
+++ b/pm/_uv.py
@@ -4,6 +4,7 @@ from __future__ import annotations
from pathlib import Path
from pm import paths
+from pm.filesystem import long_root
from pm.lock import Facts
from pm.package import InstallError
from pm.registry import get_package
@@ -35,7 +36,8 @@ def _toolchain(*, realize: bool = True, explicit: bool = False) -> tuple[Path, P
return None
raise InstallError(name, "pinned tool is unavailable", "run `hermes pm install`")
if name == "python" and target.startswith("win32") and sealed():
- writable = paths.writable_store_root()
+ # Spelled like Store spells its root, so the comparison and the copy's file calls agree.
+ writable = long_root(paths.writable_store_root())
if location[1].root != writable:
copied = _installed_location(package, lockfile, target, verify=explicit, roots=(writable,))
if copied is None:
diff --git a/pm/build_operations.py b/pm/build_operations.py
index a41b49d6b00..6a4b5cc9805 100644
--- a/pm/build_operations.py
+++ b/pm/build_operations.py
@@ -7,7 +7,7 @@ from pathlib import Path
import sys
from types import MappingProxyType
-from pm.filesystem import native
+from pm.filesystem import long_root, native
from pm.install import InstalledPackage
from pm.lock import Lockfile
from pm.package import InstallError
@@ -164,6 +164,8 @@ def verified_tools(names: Sequence[str], *, source_store: Path, target: str,
source_store = Path(source_store).resolve()
if not (source_store / "facts.json").is_file():
raise InstallError("tools", f"source facts missing: {source_store}")
+ # Admission walks and digests whole tool trees: spell the root like Store does.
+ source_store = long_root(source_store)
facts = Facts(source_store / "facts.json", strict=True)
lock = lock if lock is not None else _lockfile()
entries, envs = {}, []
diff --git a/pm/install.py b/pm/install.py
index e4648feabda..89b5c210d6f 100644
--- a/pm/install.py
+++ b/pm/install.py
@@ -91,7 +91,7 @@ def _installed_location(package: Package, lockfile: Lockfile, target: str, *,
store = Store(root)
facts = _facts() if root == paths.store_root() else Facts(root / "facts.json")
fact = facts.get(package.name)
- if not fact or not facts.installed(package.name, None, root):
+ if not fact or not facts.installed(package.name, None, store.root):
continue
binary = package.binary(store.entry(fact["entry"]), target)
if binary is not None and not binary.is_file():
@@ -100,7 +100,7 @@ def _installed_location(package: Package, lockfile: Lockfile, target: str, *,
continue
if verify and not _entry_verified(package, fact, store, target):
continue
- if facts.installed(package.name, lockfile.version(package.name), root,
+ if facts.installed(package.name, lockfile.version(package.name), store.root,
_identity(lockfile, package.name, target)):
return facts, store
if (allow_outdated and fact.get("target") == target
@@ -564,7 +564,7 @@ def ensure(
raise _refuse_lazy(name, ", ".join(p.name for p in missing))
if missing:
store = _operation.lock() if _operation is not None else Store(paths.writable_store_root())
- facts = _facts() if store.root == paths.store_root() else Facts(store.root / "facts.json")
+ facts = _facts() if store.root == _store().root else Facts(store.root / "facts.json")
for package in missing:
# Publication may change entries; do not carry observations across it.
checked.clear()
diff --git a/pm/lock.py b/pm/lock.py
index e13773ea7af..4dce1e5f82d 100644
--- a/pm/lock.py
+++ b/pm/lock.py
@@ -52,8 +52,11 @@ def _read(path: Path, *, strict: bool = False) -> dict:
# the next _write would silently discard every installed-state
# record. Keep the bytes for post-mortem.
try:
+ from pm.filesystem import long_root
from pm.paths import store_root
- if path.parent == store_root() and (store_root().parent / "manifest.json").is_file():
+ # A Store-built facts path carries the store's long spelling; compare like with like.
+ if (long_root(path.parent) == long_root(store_root())
+ and (store_root().parent / "manifest.json").is_file()):
import logging
logging.getLogger(__name__).warning("invalid shipped state file: %s", path)
else:
@@ -160,8 +163,11 @@ class Facts:
"""Publish all tool digests after packaging finishes changing their bytes."""
from pm.store import tree_digest
+ from pm.filesystem import long_root
+
packages = _read(self.path, strict=True)["packages"]
- root = store_root.resolve()
+ # Digests walk whole tool trees: the long spelling keeps them past MAX_PATH.
+ root = long_root(store_root.resolve())
count = 0
for name, fact in packages.items():
if not isinstance(fact, dict):
diff --git a/pm/packages.py b/pm/packages.py
index e6308ee51ef..0f59caa1e1e 100644
--- a/pm/packages.py
+++ b/pm/packages.py
@@ -12,7 +12,7 @@ import tempfile
from pathlib import Path
from typing import Optional
-from pm.filesystem import native
+from pm.filesystem import long_root, native
from pm.package import (
DebPackage,
InstallError,
@@ -324,13 +324,16 @@ def uv_cache_dir() -> Path:
try:
from pm.paths import store_root
- payload_cache = store_root().parent / "uv-cache"
+ # uv's cache trees run deep; both roots get the long spelling so
+ # the copy is not cut at MAX_PATH. The returned path stays ordinary.
+ payload_cache = long_root(store_root().parent / "uv-cache")
if payload_cache.is_dir():
- machine_cache.mkdir(parents=True, exist_ok=True)
+ seeded = long_root(machine_cache)
+ seeded.mkdir(parents=True, exist_ok=True)
for entry in payload_cache.iterdir():
if entry.name == ".seeded":
continue
- dest = machine_cache / entry.name
+ dest = seeded / entry.name
if not dest.exists():
(
shutil.copytree(entry, dest)