Skip to content

Commit 514b1b3

Browse files
authored
fix: handle missing cm-cli gracefully in comfy update (#419)
1 parent 8baa240 commit 514b1b3

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

comfy_cli/cmdline.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,10 @@ def update(
416416
check=True,
417417
)
418418

419-
custom_nodes.command.update_node_id_cache()
419+
try:
420+
custom_nodes.command.update_node_id_cache()
421+
except (FileNotFoundError, subprocess.CalledProcessError) as e:
422+
rprint(f"[yellow]Failed to update node id cache: {e}[/yellow]")
420423

421424

422425
@app.command(help="Run API workflow file using the ComfyUI launched by `comfy launch --background`")

tests/comfy_cli/test_cmdline_python_resolution.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ def test_uses_resolved_python(self, tmp_path):
2525
assert pip_call is not None, "pip install call not found"
2626
assert pip_call[0] == "/resolved/python"
2727

28+
def test_update_comfy_succeeds_when_cm_cli_missing(self, tmp_path):
29+
"""Regression test for #403: comfy update must not crash when cm-cli is absent."""
30+
with (
31+
patch("comfy_cli.cmdline.resolve_workspace_python", return_value="/resolved/python"),
32+
patch.object(cmdline.workspace_manager, "workspace_path", str(tmp_path)),
33+
patch("comfy_cli.cmdline.os.chdir"),
34+
patch("comfy_cli.cmdline.subprocess.run"),
35+
patch(
36+
"comfy_cli.cmdline.custom_nodes.command.update_node_id_cache",
37+
side_effect=FileNotFoundError("cm-cli not found"),
38+
) as mock_cache,
39+
):
40+
cmdline.update(target="comfy")
41+
mock_cache.assert_called_once()
42+
2843

2944
class TestDependency:
3045
def test_passes_python_to_compiler(self, tmp_path):

0 commit comments

Comments
 (0)