diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 1cf6e459..cdb27c02 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -2476,8 +2476,18 @@ def _update_via_zip(args): ) else: # Use sys.executable to explicitly call the venv's pip module, - # avoiding PEP 668 'externally-managed-environment' errors on Debian/Ubuntu + # avoiding PEP 668 'externally-managed-environment' errors on Debian/Ubuntu. + # Some environments lose pip inside the venv; bootstrap it back with + # ensurepip before trying the editable install. pip_cmd = [sys.executable, "-m", "pip"] + try: + subprocess.run(pip_cmd + ["--version"], cwd=PROJECT_ROOT, check=True, capture_output=True) + except subprocess.CalledProcessError: + subprocess.run( + [sys.executable, "-m", "ensurepip", "--upgrade", "--default-pip"], + cwd=PROJECT_ROOT, + check=True, + ) try: subprocess.run(pip_cmd + ["install", "-e", ".[all]", "--quiet"], cwd=PROJECT_ROOT, check=True) except subprocess.CalledProcessError: @@ -2863,8 +2873,18 @@ def cmd_update(args): ) else: # Use sys.executable to explicitly call the venv's pip module, - # avoiding PEP 668 'externally-managed-environment' errors on Debian/Ubuntu + # avoiding PEP 668 'externally-managed-environment' errors on Debian/Ubuntu. + # Some environments lose pip inside the venv; bootstrap it back with + # ensurepip before trying the editable install. pip_cmd = [sys.executable, "-m", "pip"] + try: + subprocess.run(pip_cmd + ["--version"], cwd=PROJECT_ROOT, check=True, capture_output=True) + except subprocess.CalledProcessError: + subprocess.run( + [sys.executable, "-m", "ensurepip", "--upgrade", "--default-pip"], + cwd=PROJECT_ROOT, + check=True, + ) try: subprocess.run(pip_cmd + ["install", "-e", ".[all]", "--quiet"], cwd=PROJECT_ROOT, check=True) except subprocess.CalledProcessError: