`comfy launch --background` fails with FileNotFoundError when comfy-cli is invoked by path
Maintainer thường phản hồi trong vòng 1 ngày
@RaphaelFakhri đang làm issue này rồi.
Từ ngày 2/10/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu tại comfy_cli/command/launch.py, ở background_launch(), và kiểm tra cách lệnh được truyền cho subprocess.Popen được xây dựng và khởi chạy. Chạy lại reproducer virtualenv khi comfy không có trong PATH, sau đó xác minh rằng cùng CLI được gọi bằng đường dẫn đó có thể khởi chạy ở chế độ nền mà không gặp FileNotFoundError và Workspace được thực thi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
background_launch() re-execs the CLI as a bare "comfy" through subprocess.Popen (no shell=True), so the child is resolved via PATH. When comfy-cli is invoked by its own path from a virtualenv that hasn't been activated — e.g. /path/to/.venv/bin/comfy launch --background — the child spawn raises FileNotFoundError and the launch dies with an unhandled traceback.
This is a normal way to use a Python console script (it's how a script or launcher invokes a tool it installed into a project-local venv), and comfy-cli otherwise anchors subprocesses properly — resolve_python.py and uv.py use sys.executable throughout. Only this call site assumes PATH.
To Reproduce
python3 -m venv .venv-comfy
.venv-comfy/bin/pip install comfy-cli
# a stand-in workspace is enough to reach the failing call
mkdir -p fake-ws && echo 'print("hi")' > fake-ws/main.py
# the key condition: `comfy` is NOT on PATH
env -i HOME="$HOME" PATH=/usr/bin:/bin \
./.venv-comfy/bin/comfy --skip-prompt --workspace="$PWD/fake-ws" launch --background
Environment
- comfy-cli 1.15.0
- Python 3.11, Linux (originally hit on macOS / Apple silicon)
- comfy-cli installed into a project-local venv and invoked without activating it
Observed
FileNotFoundError: [Errno 2] No such file or directory: 'comfy'
…raised from comfy_cli/command/launch.py → background_launch → subprocess.Popen.
Expected behavior
The background launch should start, as it does when the same binary's directory happens to be on PATH. Re-running the identical command with only PATH="$PWD/.venv-comfy/bin:$PATH" changed gets past the spawn and executes the workspace — PATH is the only variable.
Cause
comfy_cli/command/launch.py, in background_launch():
cmd = [
"comfy",
f"--workspace={os.path.abspath(os.getcwd())}",
"launch",
]
...
process = subprocess.Popen(
cmd,
stdout=logfh,
stderr=subprocess.STDOUT,
env=env,
)
cmd[0] is a bare name, so Popen resolves it against PATH — which need not contain the comfy-cli that is currently running.
Suggested fix
Anchor the re-exec to the running installation rather than to PATH. Either of these is a no-op when comfy is on PATH:
cmd = [sys.argv[0], f"--workspace={...}", "launch"] # the path actually invoked
cmd = [sys.executable, "-m", "comfy_cli", f"--workspace={...}", "launch"] # interpreter-anchored
sys.executable-based spawning would also match what resolve_python.py / uv.py already do.
Secondary note
Because the failure happens after the parent prints Launching ComfyUI from: <workspace>, it reads as though ComfyUI itself failed to start, which sends you looking at the workspace and its models rather than at the CLI. Catching FileNotFoundError around the spawn and reporting something like "could not re-exec comfy; is it on PATH?" would make the failure self-explanatory even before the fix above.
Nice to have
- Terminal output
- Screenshots
Additional context
Add any other context about the problem here.
- Ngôn ngữ chính
- Python
- Star
- 1k
- Fork
- 176
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 87
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Comfy-Org/comfy-cli
-
test_file_utils umask tests assert against a umask the code never reads (import-time _UMASK), so they only pass on a 0o022 hostCó thể đã có người làm @neverbiasu đã nhận 10 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Comfy-Org/comfy-cli#907 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
Comfy-Org/comfy-cli#781 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Comfy-Org/comfy-cli#670 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
UI→API conversion sends LOAD_3D viewport_state as "" where the frontend sends the viewport cameraĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 53/100
Comfy-Org/comfy-cli#1126 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Comfy-Org/comfy-cli
Issue tương tự
-
add entry to blockĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"Có thể đã có người làm @0z5a đã nhận hôm nay. Đang mởneeds-triage
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
plot_graph crashes when a mesh node has no m2m edgeCó thể đã có người làm @tygvi đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
mllam/neural-lam#883 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
future-agi/future-agi#4092 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
transcript analytics: a text whose only protected spans the prose pass redacts is withheld wholeĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
WingedGuardian/GENesis-AGI#4641 ·
Maintainer thường phản hồi trong vòng 1 ngày