diff --git a/unsloth_cli/commands/start.py b/unsloth_cli/commands/start.py index 7a26cdfa12..919b4bf9d5 100644 --- a/unsloth_cli/commands/start.py +++ b/unsloth_cli/commands/start.py @@ -2393,7 +2393,7 @@ def _managed_node_tools() -> Optional[tuple[Path, Path, bool]]: from utils.node_runtime import managed_node_binary, resolve_node_executable node = Path(managed_node_binary()) - except Exception: + except (ImportError, OSError, RuntimeError, TypeError, ValueError): return None npm = node.with_name("npm.cmd" if os.name == "nt" else "npm") try: diff --git a/unsloth_cli/tests/test_start.py b/unsloth_cli/tests/test_start.py index 64006ca983..30c43dbfd2 100644 --- a/unsloth_cli/tests/test_start.py +++ b/unsloth_cli/tests/test_start.py @@ -268,6 +268,15 @@ def test_npm_executable_uses_studio_managed_node(monkeypatch, tmp_path): assert start._npm_executable() == str(npm) +def test_managed_node_probe_tolerates_unsupported_path_flavour(monkeypatch): + def unsupported_backend_path(): + raise RuntimeError("unsupported path flavour") + + monkeypatch.setattr(start, "ensure_studio_backend_path", unsupported_backend_path) + + assert start._managed_node_tools() is None + + def test_npm_executable_uses_managed_npm_when_system_node_has_none(monkeypatch, tmp_path): start.ensure_studio_backend_path() from utils import node_runtime