Skip to content

Commit 9eebf31

Browse files
committed
fix(cache): derive sqlite db suffix from python_executable path, not python_version config field
python_version in config was unreliable/missing, causing _connect_cache to open cache_<env_id>.sqlite (no suffix) while redis_key_prefix correctly resolved py3.11 from the executable path — opening cache_<env_id>-py3.11.sqlite. Snapshot keys written by save were never found by revert as a result. Fix mirrors redis_key_prefix logic: regex on executable path, subprocess fallback for edge cases like the python3 symlink on 3.7. Modified: • src/omnipkg/core.py (+11/-2 lines) [gitship-generated]
1 parent 77a322e commit 9eebf31

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/omnipkg/core.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7059,8 +7059,17 @@ def _connect_cache(self) -> bool:
70597059
# SQLite initialization (runs if Redis disabled or failed)
70607060
safe_print("✅ SQLite cache initialized.")
70617061
try:
7062-
py_ver = self.config.get("python_version", "").replace(".", "")
7063-
suffix = f"-py{self.config.get('python_version', '')}" if py_ver else ""
7062+
_py_exe = self.config.get("python_executable", sys.executable)
7063+
_m = re.search(r"python(3\.\d+)", _py_exe)
7064+
if _m:
7065+
_py_ver_str = _m.group(1)
7066+
else:
7067+
try:
7068+
_r = subprocess.run([_py_exe, "-c", "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"], capture_output=True, text=True, timeout=2)
7069+
_py_ver_str = _r.stdout.strip()
7070+
except Exception:
7071+
_py_ver_str = f"{sys.version_info.major}.{sys.version_info.minor}"
7072+
suffix = f"-py{_py_ver_str}"
70647073
sqlite_db_path = self.config_manager.config_dir / f"cache_{self.env_id}{suffix}.sqlite"
70657074
self.cache_client = SQLiteCacheClient(db_path=sqlite_db_path)
70667075
if not self.cache_client.ping():

0 commit comments

Comments
 (0)