The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): an unwritable marker or checkout lock says why the update needs it and how to fix it
Teknium97ca549f6dba
diff --git a/hermes_cli/update_lock.py b/hermes_cli/update_lock.pyindex 37daecedc78..0d8fd1f3377 100644--- a/hermes_cli/update_lock.py+++ b/hermes_cli/update_lock.py@@ -926,8 +926,10 @@ def describe_holder(holder: UpdateHolder | None) -> str:return (f"✗ Cannot lock this install for the update: {holder.reason}.\n""\n"- " Updating without the lock could let two updates corrupt the install.\n"- " Run `hermes update` as the user that owns the install."+ " Updating without the lock could let two updates corrupt the install, or run\n"+ " under a Desktop app, gateway or installer that cannot see it. Make that path\n"+ " writable (fix its owner or permissions, or remount a read-only filesystem\n"+ " read-write), or run `hermes update` as the user that owns the install.")minutes, seconds = divmod(int(max(0 if holder is None else holder.age_seconds, 0)), 60)elapsed = f"{minutes}m {seconds}s" if minutes else f"{seconds}s"@@ -1074,7 +1076,8 @@ def _acquire_checkout(install_root: Path) -> UpdateHolder | None:return Nonefd, writable = _open_lock_file(path)if fd is None:- return UpdateHolder(pid=0, age_seconds=0.0, reason=f"{path} is not writable ({writable})")+ return UpdateHolder(pid=0, age_seconds=0.0, reason=f"{path} is not writable ({writable}); the update "+ "locks the checkout there, in its git directory, which git must write too")found = os.fstat(fd)if not S_ISREG(found.st_mode) or found.st_nlink != 1:# A hard link (or special file) at the name: truncating it would rewrite data outside@@ -1361,6 +1364,12 @@ def _publish_exclusive(path: Path, body: bytes) -> bool:return True+def _marker_unwritable(path: Path, exc: OSError) -> str:+ """Why an unwritable marker location refuses the update, not just that it is unwritable."""+ return (f"{path} is not writable ({exc}); the update records itself there so the Desktop app, "+ "gateways, installers and other updaters wait for it")++# Per-process claim depth for each marker path: nested UpdateLocks (an update's completion run# in-process, venv_sync finishing a tail) share one claim, released by the outermost._CLAIMS: dict[str, int] = {}@@ -1426,7 +1435,7 @@ class UpdateLock:try:self.path.parent.mkdir(parents=True, exist_ok=True)except OSError as exc:- self.holder = UpdateHolder(pid=0, age_seconds=0.0, reason=f"{self.path.parent} is not writable ({exc})")+ self.holder = UpdateHolder(pid=0, age_seconds=0.0, reason=_marker_unwritable(self.path.parent, exc))return False_sweep_dead_tmp_siblings(self.path)if _CLAIMS.get(str(self.path)) is None:@@ -1466,7 +1475,7 @@ class UpdateLock:self.holder = UpdateHolder(pid=0, age_seconds=0.0)return Falseexcept OSError as exc:- self.holder = UpdateHolder(pid=0, age_seconds=0.0, reason=f"{self.path} is not writable ({exc})")+ self.holder = UpdateHolder(pid=0, age_seconds=0.0, reason=_marker_unwritable(self.path, exc))return Falseself.holder = read_live_update(path=self.path, install_root=self.install_root) \or UpdateHolder(pid=0, age_seconds=0.0)diff --git a/tests/hermes_cli/test_update_lock.py b/tests/hermes_cli/test_update_lock.pyindex 04de47c0b25..f91755c16d9 100644--- a/tests/hermes_cli/test_update_lock.py+++ b/tests/hermes_cli/test_update_lock.py@@ -467,6 +467,20 @@ def test_unwritable_marker_location_refuses_instead_of_running_unlocked(tmp_pathassert "Cannot lock this install" in describe_holder(lock.holder)++def test_an_unwritable_marker_location_says_why_the_update_needs_it_and_how_to_fix_it(tmp_path):+ """Review P2 (5411135165): the refusal stays (the marker is what the Desktop gate, gateways and+ the other updaters read), so it must say what the path is for and how to make it writable."""+ blocker = tmp_path / "home"+ blocker.write_bytes(b"a file where the marker directory should be")+ lock = UpdateLock(path=blocker / "marker")++ assert lock.acquire() is False+ message = describe_holder(lock.holder)+ assert str(blocker) in message+ assert "Desktop app" in message and "other updaters" in message, message+ assert "read-only filesystem" in message, message+_HOLD_CHECKOUT = """import sys, timesys.path.insert(0, sys.argv[1])