The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(platforms): make QR fallback install tip target the active interpreter
Kevin Rajan505b36b7afc6
diff --git a/gateway/platforms/qqbot/onboard.py b/gateway/platforms/qqbot/onboard.pyindex 44a0b917b5c..c804cf7fc3c 100644--- a/gateway/platforms/qqbot/onboard.py+++ b/gateway/platforms/qqbot/onboard.py@@ -4,6 +4,7 @@from __future__ import annotationsimport logging+import sysimport timefrom enum import IntEnumfrom typing import Optional, Tuple@@ -97,7 +98,7 @@ def qr_register(timeout_seconds: int = 600) -> Optional[dict]:print(f" Scan the QR code above, or open this URL directly:\n {url}")else:print(f" Open this URL in QQ on your phone:\n {url}")- print(" Tip: pip install qrcode to display a scannable QR code here")+ print(f" Tip: {sys.executable} -m pip install qrcode to display a scannable QR code here")print()while time.monotonic() < deadline:try:diff --git a/hermes_cli/telegram_managed_bot.py b/hermes_cli/telegram_managed_bot.pyindex fa505c3de79..8b6d08bb651 100644--- a/hermes_cli/telegram_managed_bot.py+++ b/hermes_cli/telegram_managed_bot.py@@ -76,7 +76,7 @@ def render_qr_terminal(url: str) -> str:def print_qr_code(url: str, *, include_link: bool = True) -> None:"""Print a QR code to stdout, with URL fallback if qrcode is missing."""- print(render_qr_terminal(url) or " (Install 'qrcode' for a scannable QR code: pip install qrcode)")+ print(render_qr_terminal(url) or f" (Install 'qrcode' for a scannable QR code: {sys.executable} -m pip install qrcode)")if include_link:print(f" Link: {url}")diff --git a/plugins/platforms/feishu/adapter.py b/plugins/platforms/feishu/adapter.pyindex f63817630b0..69c62c5a547 100644--- a/plugins/platforms/feishu/adapter.py+++ b/plugins/platforms/feishu/adapter.py@@ -30,6 +30,7 @@ import loggingimport mimetypesimport osimport re+import sysimport threadingimport timeimport uuid@@ -4103,7 +4104,7 @@ def _qr_register_inner(*, initial_domain: str, timeout_seconds: int) -> Optionalprint(f"\n Scan the QR code above, or open this URL directly:\n {qr_url}")else:print(f" Open this URL in Feishu / Lark on your phone:\n\n {qr_url}\n")- print(" Tip: pip install qrcode to display a scannable QR code here next time")+ print(f" Tip: {sys.executable} -m pip install qrcode to display a scannable QR code here next time")print()result = _poll_registration(device_code=begin["device_code"], interval=begin["interval"],diff --git a/plugins/platforms/wecom/adapter.py b/plugins/platforms/wecom/adapter.pyindex be2cd63a046..9213740fc76 100644--- a/plugins/platforms/wecom/adapter.py+++ b/plugins/platforms/wecom/adapter.py@@ -10,6 +10,7 @@ import asyncioimport jsonimport loggingimport re+import sysimport timeimport uuidfrom datetime import datetime, timezone@@ -674,7 +675,7 @@ def qr_scan_for_bot_info(*, timeout_seconds: int = _QR_POLL_TIMEOUT) -> Optionalprint(f"\n Scan the QR code above, or open this URL directly:\n {page_url}")except Exception:print(f" Open this URL in WeCom on your phone:\n\n {page_url}\n")- print(" Tip: pip install qrcode to display a scannable QR code here next time")+ print(f" Tip: {sys.executable} -m pip install qrcode to display a scannable QR code here next time")print("\n Fetching configuration results...", end="", flush=True)deadline = time.monotonic() + timeout_secondsquery_url = f"{_QR_QUERY_URL}?scode={urllib.parse.quote(scode)}"diff --git a/tests/hermes_cli/test_telegram_managed_bot.py b/tests/hermes_cli/test_telegram_managed_bot.pyindex 5b3e805528e..7768515e9cf 100644--- a/tests/hermes_cli/test_telegram_managed_bot.py+++ b/tests/hermes_cli/test_telegram_managed_bot.py@@ -36,6 +36,17 @@ class TestQRCode:captured = capsys.readouterr()assert "https://t.me/newbot/Bot/test_bot" in captured.out+ def test_print_qr_code_tip_targets_active_interpreter(self, capsys):+ # Regression for #111695: a bare `pip install` targets the wrong+ # environment when Hermes runs in an isolated venv. The fallback tip+ # must name the interpreter that is actually running.+ import sys++ with patch.dict("sys.modules", {"qrcode": None}):+ print_qr_code("https://t.me/newbot/Bot/test_bot")+ captured = capsys.readouterr()+ assert sys.executable in captured.out+class TestCreatePairing:def test_success(self):