From 9009169eeba34460fcbb6e6faac7db2ac94292ab Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 28 Mar 2026 14:54:49 -0700 Subject: [PATCH] fix: recover updater when venv pip is missing (#3608) Some environments lose pip inside the venv. Before invoking pip install, check pip --version and bootstrap with ensurepip if missing. Applied to both update code paths (_update_via_zip and cmd_update). Salvaged from PR #3359. Co-authored-by: Git-on-my-level --- hermes_cli/main.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 1cf6e459d..cdb27c024 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: