Skip to content

Conversation

@Adios
Copy link

@Adios Adios commented Dec 17, 2025

This PR addresses two critical issues with the ComfyUI-Manager deployment: ensuring correct initialization in persistent volumes and preventing system library crashes caused by opencv-python.

  1. Robust Initialization Logic
  • Added logic to check if ComfyUI-Manager (case-insensitive) already exists in the custom_nodes directory.
  • Implemented a robust loop for the existence check to avoid issues with find on symlinked paths.
  • If the manager is missing, it is copied from the pre-installed location in the image to the persistent volume.
  • If it exists, initialization is skipped to preserve user updates.
  1. Support Standard opencv-python (Fix for libGL.so.1 crash)
    Many custom nodes (e.g., ComfyUI-Impact-Pack via ultralytics) rely on the standard opencv-python package, which requires system-level GL libraries often missing in headless container environments.

Previously, I attempted to force opencv-python-headless via pip_overrides.json, but this proved unreliable for recursive dependencies.

The updated solution:

  • Dockerfile: Added installation of libgl1 and libglib2.0-0. This satisfies the dependencies for the standard opencv-python wheel, allowing it to run without crashing.
  • Entrypoint: Removed the complex pip_overrides.json injection logic, as it is no longer necessary.

This approach ensures a "batteries-included" experience where the Manager and popular nodes (like Impact Pack) work immediately upon first launch without requiring manual user intervention or complex pip overrides.

Closes #15

…odes

This commit modifies the ComfyUI entrypoint script to correctly handle the
initialization of ComfyUI-Manager within the persistent `custom_nodes` volume.

Changes include:
- Added logic to check if `ComfyUI-Manager` (case-insensitive) already exists
  in the `custom_nodes` directory.
- Implemented a robust bash loop for the existence check to avoid issues with
  `find` on symlinked paths.
- If the manager is missing, it is copied from the pre-installed location in the
  image to the persistent volume.
- If the manager exists, the initialization is skipped to prevent overwriting
  user updates or configurations.

This ensures that the pre-installed manager is available on the first run while
preserving it across subsequent container restarts and builds.
This commit configures ComfyUI-Manager to enforce `opencv-contrib-python-headless` instead of the standard `opencv-python` package.

Changes:
1.  **entrypoint.sh**:
    *   Dynamically detects if the installed ComfyUI version uses the new System User API (by checking for `get_system_user_directory`).
    *   Creates the appropriate configuration directory (`__manager` for new versions, `default/ComfyUI-Manager` for old versions) in the user's volume.
    *   Copies `pip_overrides.json.template` from the image to `pip_overrides.json` in the user configuration directory.
    *   Displays a prominent notification message during initialization.

This approach ensures that even if custom nodes request the standard OpenCV package, the Manager will intercept the request and install the headless version (specifically the `contrib` variant to support extra modules), preventing system library crashes (libGL) across different ComfyUI versions.
@Adios Adios changed the title fix(comfy): ensure safe initialization of ComfyUI-Manager in custom_nodes Fix ComfyUI-Manager initialization and enforce headless OpenCV stability Dec 18, 2025
The `ultralytics` package (required by ComfyUI-Impact-Subpack) pulls in `opencv-python` as a dependency. In the headless Docker environment, this caused crashes due to missing GL libraries.

Attempting to fix this via `pip_overrides.json` in ComfyUI-Manager (forcing `opencv-python-headless` or `dgenerate-ultralytics-headless`) was problematic because `pip_overrides` struggles with recursive dependency overrides.

This commit resolves the issue by installing the necessary system libraries (`libgl1`, `libglib2.0-0`) in the Dockerfile. This allows the standard `opencv-python` wheel to function correctly, eliminating the need for complex override logic in the entrypoint script.

Changes:
- services/comfy/Dockerfile: Install `libgl1` and `libglib2.0-0`.
- services/comfy/entrypoint.sh: Remove `pip_overrides.json` injection logic.
@Adios Adios changed the title Fix ComfyUI-Manager initialization and enforce headless OpenCV stability Fix ComfyUI-Manager initialization and support standard opencv-python (add system GL libs) Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ComfyUI-Manager installed in image but missing from custom_nodes volume at runtime

1 participant