Skip to content

Commit ffe596d

Browse files
committed
fix: replace OMNIPKG_ENV_ID_OVERRIDE with OMNIPKG_DAEMON_TEMP_ID to prevent KB key corruption
_get_venv_temp_dir() was using sha1(sys.prefix + optional project_root) producing a hash divergent from ConfigManager's md5(_canonical_path_str(sys.prefix))[:8]. The resulting wrong hash was being injected into workers via OMNIPKG_ENV_ID_OVERRIDE, which package_meta_builder and core.py consumed as the authoritative env_id, causing all bubble installs to write KB entries under the daemon's incorrect env_id instead of the environment's canonical one. Post-install verification then recomputed the correct env_id, found no matching KB entry, and raised "Installation reported success but not found". Fix: rename env var to OMNIPKG_DAEMON_TEMP_ID (log/socket/pid path only) and align hash logic to match ConfigManager exactly. Modified: • src/omnipkg/isolation/worker_daemon.py (+9/-12 lines) [gitship-generated]
1 parent 4f7a0d9 commit ffe596d

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

src/omnipkg/isolation/worker_daemon.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -331,21 +331,18 @@ def _ensure_worker_config(python_exe: str, site_packages: str, multiversion_base
331331
OMNIPKG_TEMP_DIR = os.path.join(tempfile.gettempdir(), "omnipkg")
332332

333333
def _get_venv_temp_dir() -> str:
334-
# 1. Check for the override first (Symmetry with ConfigManager)
335-
override = os.environ.get("OMNIPKG_ENV_ID_OVERRIDE")
334+
# Use OMNIPKG_DAEMON_TEMP_ID for socket/log/pid path consolidation only.
335+
# This is separate from env_id used for KB keys.
336+
override = os.environ.get("OMNIPKG_DAEMON_TEMP_ID")
336337
if override:
337338
venv_hash = override
338339
else:
339-
# Fallback to the original hash logic
340+
# Match ConfigManager exactly: md5(_canonical_path_str(sys.prefix))[:8]
340341
import hashlib
341-
identity = sys.prefix
342-
try:
343-
project_root = Path(__file__).resolve().parent.parent.parent
344-
if (project_root / "pyproject.toml").exists():
345-
identity = f"{sys.prefix}:{project_root}"
346-
except Exception:
347-
pass
348-
venv_hash = hashlib.sha1(identity.encode()).hexdigest()[:10]
342+
p = os.path.realpath(sys.prefix).replace("\\", "/").rstrip("/")
343+
if os.name == "nt":
344+
p = p.lower()
345+
venv_hash = hashlib.md5(p.encode()).hexdigest()[:8]
349346

350347
d = os.path.join(OMNIPKG_TEMP_DIR, venv_hash)
351348
os.makedirs(d, exist_ok=True)
@@ -2199,7 +2196,7 @@ def _spawn_process(self):
21992196
env["OMNIPKG_SITE_PACKAGES"] = self.site_packages
22002197
if os.environ.get("UV_FFI_PROFILE"):
22012198
env["UV_FFI_PROFILE"] = "1"
2202-
env["OMNIPKG_ENV_ID_OVERRIDE"] = _VENV_TEMP_DIR.split(os.sep)[-1]
2199+
env["OMNIPKG_DAEMON_TEMP_ID"] = _VENV_TEMP_DIR.split(os.sep)[-1]
22032200
# 🔑 ENSURE per-interpreter config file exists next to this interpreter.
22042201
# Without this, the worker falls back to global config (wrong multiversion_base).
22052202
# _ensure_worker_config writes a lightweight JSON that ConfigManager finds first.

0 commit comments

Comments
 (0)