Skip to content

Commit ac8f07a

Browse files
committed
fix(venv): use ~/.local/omnipkg for system Python instead of /usr
- Detects system Python in /usr, /usr/local, /opt paths - Uses safe user directory for Alpine/Arch Docker containers - Prevents permission errors when installing managed interpreters - Keeps existing venv detection logic intact
1 parent 1b8efc4 commit ac8f07a

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/omnipkg/core.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ def _get_venv_root(self) -> Path:
441441

442442
CRITICAL: When running from a managed interpreter (e.g., inside .omnipkg/interpreters/),
443443
we must find the ORIGINAL venv root, not create nested structures.
444+
445+
NEW: For system Python (no venv), use ~/.local/omnipkg instead of sys.prefix
444446
"""
445447
override = os.environ.get("OMNIPKG_VENV_ROOT")
446448
if override:
@@ -502,6 +504,18 @@ def _get_venv_root(self) -> Path:
502504
return search_dir
503505
search_dir = search_dir.parent
504506

507+
# ============================================================================
508+
# NEW FIX: For system Python (no venv found), use user directory
509+
# ============================================================================
510+
# Check if we're using system Python (in /usr, /usr/local, etc.)
511+
is_system_python = str(current_executable).startswith(('/usr/', '/usr/local/', '/opt/'))
512+
513+
if is_system_python:
514+
# Use user-local directory instead of sys.prefix
515+
safe_user_dir = Path.home() / ".local" / "omnipkg"
516+
safe_user_dir.mkdir(parents=True, exist_ok=True)
517+
return safe_user_dir
518+
505519
# Only use sys.prefix as a last resort if all else fails.
506520
return Path(sys.prefix)
507521

0 commit comments

Comments
 (0)