Skip to content

Self-hosted AI workspace.

Python

fix(cookbook): don't 500 the packages panel when an optional package crashes on import (#2618)

Dividesbyzer0d07449e55317
diff --git a/routes/shell_routes.py b/routes/shell_routes.py
index 3ffaab522..a3126abbb 100644
--- a/routes/shell_routes.py
+++ b/routes/shell_routes.py
@@ -1209,6 +1209,12 @@ def setup_shell_routes() -> APIRouter:
pkg["installed"] = False
except importlib_metadata.PackageNotFoundError:
pkg["installed"] = False
+ except Exception:
+ # Installed but crashes on import — e.g. a CUDA build of
+ # llama-cpp-python raising FileNotFoundError when the CUDA
+ # toolkit dir is absent. One broken optional package must not
+ # 500 the entire packages panel; report it as not usable.
+ pkg["installed"] = False
if pkg.get("installed"):
update_status = _package_pip_update_status(pkg, probe)