ComfyUI-Manager icon indicating copy to clipboard operation
ComfyUI-Manager copied to clipboard

[Bug] Restart command strips quotes from CLI arguments containing spaces

Open gershu-ar opened this issue 2 months ago • 3 comments

Describe the bug When ComfyUI-Manager restarts ComfyUI after installing or updating custom nodes, by clicking on the UI's Restart button, it reconstructs the startup command directly from sys.argv. Since sys.argv elements lose their original shell quotes during Python initialization, joining them without escaping or re-quoting causes space-containing arguments to break upon restart.

How to reproduce

  1. Launch ComfyUI using any CLI argument that contains spaces wrapped in quotes, for example: python main.py --browser-profile "Profile 1"
  2. Update an extension or trigger a restart via ComfyUI-Manager.
  3. Observe the restart command generated by Manager: Command: [..., '--browser-profile', 'Profile 1']
  4. main.py crashes on boot with main.py: error: unrecognized arguments: 1 because Profile 1 was passed without quotes.

Expected behavior Arguments in sys.argv containing spaces should be safely escaped or re-quoted (lusing shlex.quote() or subprocess.list2cmdline()) when rebuilding the restart command line string.

gershu-ar avatar Oct 03 '26 03:10 gershu-ar

This looks like an argument-preservation issue in the Manager's restart implementation. Paths containing spaces are particularly sensitive when command-line arguments are reconstructed.

I've developed an independent restart extension for ComfyUI that may be worth comparing:

ComfyUI Restart Control https://github.com/andreszs/ComfyUI-Restart-Control

It uses a separate, guarded restart mechanism designed to preserve the original ComfyUI launch arguments, with additional support for queue-aware restarts and selective custom-node loading.

I haven't verified this particular quoted-argument scenario against your reproduction, so I wouldn't claim it fixes the Manager bug itself, but it could be useful as an alternative implementation to test.

It's also available through ComfyUI's new built-in Extension Manager. Just search for Restart Control under Nodes Manager.

andreszs avatar Oct 28 '26 21:10 andreszs

I haven't verified this particular quoted-argument scenario against your reproduction, so I wouldn't claim it fixes the Manager bug itself, but it could be useful as an alternative implementation to test.

I discovered the bug while implementing a custom browser solution in Comfy. There's a still pending PR with the code in it. Very simple modifications, perhaps you can test it yourself to check if quoting is maintained in your solution.

In my code, the example goes: --browser-path "C:\Users\XXXX\AppData\Local\Chromium\Application\chrome.exe" --browser-profile "Profile 1"

"Profile 1" has a space in it, when quotes are stripped by Manager on restart call, main.py triggers the error: "1" is an unknown parameter. This will happen with any switch/CLI that uses spaces, Manager is treating all commands as pure one-liners.

gershu-ar avatar Oct 30 '26 19:10 gershu-ar

Fixed by #3488, merged into main as ecc09f1a, and by #3499 for v4, merged into manager-v4 as ad3a2b86.

On Windows os.execv joins the arguments with spaces and quotes nothing, so only the interpreter and the script path, which were quoted by hand, survived a restart. The restart command is now built in one place and every argument is quoted there. Measured on Windows 11 with your reproduction:

--browser-profile "Profile 1"
before: --browser-profile, Profile, 1
after:  --browser-profile, Profile 1

Arguments with quotation marks or a trailing backslash and empty arguments are kept as well, and a ComfyUI started with python -m from a Python path with a space now restarts too. On Linux and macOS the arguments were already passed through unchanged.

On main the fix is available by updating ComfyUI-Manager. For v4 it is not in 4.3 on PyPI; it will be in the next v4 release. Thanks for the report.

ltdrdata avatar Nov 12 '26 10:11 ltdrdata