main_dep_hints.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """Repair guidance for an unavailable declared dependency group."""
  2. def missing_optional_deps_message(surface: str, what: str, extra: str) -> str:
  3. return (
  4. f"The {surface} can't start: {what} are missing from this install.\n"
  5. "Run `hermes pm install` to prepare the declared dependencies.\n"
  6. "If an installed dependency is damaged, run `hermes pm repair`, then restart Hermes."
  7. )
  8. def smart_app_control_block_message(error: BaseException) -> str | None:
  9. """Guidance for Windows Smart App Control / Application Control blocking the embedded
  10. Python runtime's ``_ssl`` module, or ``None`` when *error* is not that case.
  11. fastapi/uvicorn import ``ssl``; when the policy blocks the ``_ssl`` DLL, the import
  12. fails with the signature ``DLL load failed ... _ssl`` — and the generic
  13. missing-deps repair loop above can never fix it, so users looped on repair
  14. (#63796). The desktop's embedded runtime is the usual victim; the CLI and the
  15. gateway run on the system Python and stay unaffected.
  16. """
  17. message = str(error)
  18. if "DLL load failed" not in message or "_ssl" not in message:
  19. return None
  20. return "\n".join([
  21. "✗ The embedded Python runtime is blocked by Windows security policy.",
  22. "",
  23. "Root cause: Python's SSL module (_ssl) could not be loaded:",
  24. f" {message}",
  25. "",
  26. "This happens when Windows Smart App Control or an Application Control",
  27. "policy blocks the embedded Python runtime that ships with Hermes Desktop.",
  28. "A repair / reinstall loop cannot fix this — the packages are not missing,",
  29. "the runtime's DLL is being blocked.",
  30. "",
  31. "Recovery options:",
  32. " 1. Use a trusted system Python installation instead of the embedded",
  33. " runtime (if your organization allows it).",
  34. " 2. Ask your IT administrator for an exemption for the Hermes Desktop",
  35. " application (Smart App Control / Application Control).",
  36. " 3. Use the CLI or gateway instead (they use your system Python).",
  37. "",
  38. "See https://aka.ms/smartappcontrol for Windows Smart App Control details.",
  39. ])