From 432ba3b7097d86231774f0dbfc5a17db750d08a8 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 25 Mar 2026 17:52:59 -0700 Subject: [PATCH] fix: use sys.executable for pip in update commands to fix PEP 668 (#3099) The update commands called bare 'pip' as fallback when uv wasn't found. On modern Debian/Ubuntu enforcing PEP 668, this resolves to system pip which refuses to install in an externally-managed environment. Use sys.executable -m pip to ensure the venv's pip is used. Fixed in both cmd_update and _update_via_zip (the PR only caught one instance). Salvaged from PR #2655 by devorun. Fixes #2648. --- hermes_cli/main.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 47bce441100..f038cf276c9 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -2439,8 +2439,9 @@ def _update_via_zip(args): cwd=PROJECT_ROOT, check=True, env=uv_env, ) else: - venv_pip = PROJECT_ROOT / "venv" / ("Scripts" if sys.platform == "win32" else "bin") / "pip" - pip_cmd = [str(venv_pip)] if venv_pip.exists() else ["pip"] + # Use sys.executable to explicitly call the venv's pip module, + # avoiding PEP 668 'externally-managed-environment' errors on Debian/Ubuntu + pip_cmd = [sys.executable, "-m", "pip"] try: subprocess.run(pip_cmd + ["install", "-e", ".[all]", "--quiet"], cwd=PROJECT_ROOT, check=True) except subprocess.CalledProcessError: @@ -2752,8 +2753,9 @@ def cmd_update(args): cwd=PROJECT_ROOT, check=True, env=uv_env, ) else: - venv_pip = PROJECT_ROOT / "venv" / ("Scripts" if sys.platform == "win32" else "bin") / "pip" - pip_cmd = [str(venv_pip)] if venv_pip.exists() else ["pip"] + # Use sys.executable to explicitly call the venv's pip module, + # avoiding PEP 668 'externally-managed-environment' errors on Debian/Ubuntu + pip_cmd = [sys.executable, "-m", "pip"] try: subprocess.run(pip_cmd + ["install", "-e", ".[all]", "--quiet"], cwd=PROJECT_ROOT, check=True) except subprocess.CalledProcessError: