Skip to content

Allow disabling prestartup auto pip install/upgrade#2851

Open
caniko wants to merge 2 commits into
Comfy-Org:manager-v4from
caniko:fix/managed-env-no-auto-install
Open

Allow disabling prestartup auto pip install/upgrade#2851
caniko wants to merge 2 commits into
Comfy-Org:manager-v4from
caniko:fix/managed-env-no-auto-install

Conversation

@caniko
Copy link
Copy Markdown

@caniko caniko commented May 4, 2026

Summary

Adds a dependency_management config key (with a
COMFYUI_MANAGER_DEPENDENCY_MANAGEMENT env override) to opt out of every
prestartup path that mutates the Python interpreter, so Manager can be
used on top of an externally-managed env without screaming subprocess
errors.

Why

When ComfyUI-Manager runs on an interpreter the user doesn't own — Nix,
Guix, distro Python, locked-down corporate images — every startup ends
the same way:

error: The interpreter at /nix/store/.../python3-3.13-env is externally
managed, [...]
[ComfyUI-Manager] Failed to restore comfyui-frontend-package
Command '[..., '-m', 'uv', 'pip', 'install',
'comfyui-frontend-package==1.42.15']' returned non-zero exit status 2.

The env already has the right packages pinned by whoever produced it;
Manager doesn't need to reinstall them, and on a read-only store it
can't. Today there's no clean way to tell it to stand down — it tries
pippython -m uv → standalone uv and only gives up after all
three fail, which produces a noisy startup and a confused user.

What changes

When dependency_management = off (or
COMFYUI_MANAGER_DEPENDENCY_MANAGEMENT=off):

  • PIPFixer.fix_broken() returns immediately. No torch rollback, no
    opencv alignment, no comfy uninstall, no comfyui-frontend-package
    reinstall.
  • The unified dependency resolver block in prestartup_script.py is
    skipped before it reaches uv pip install.
  • Per-node pip install -r requirements.txt in
    execute_lazy_install_script is skipped.

Read-only operations (pip list, pip freeze, pip show) still run,
so the UI inventory, cm-cli listings, and security_check keep
working. User-initiated installs via cm-cli install and the UI install
buttons are deliberately not gated — those are explicit actions and
shouldn't be silently swallowed.

The default is on, which preserves today's behavior bit-for-bit. No
existing user is affected unless they flip the switch.

Configuration

config.ini:

[default]
dependency_management = off

Or, without touching the config:

COMFYUI_MANAGER_DEPENDENCY_MANAGEMENT=off comfyui --enable-manager

The env var wins over the config key. Accepted "off" values are off,
false, 0, no, disabled (case-insensitive); anything else is
treated as on.

Test plan

  • Default (key/env unset) — startup behavior matches main
  • dependency_management = off — ComfyUI starts with
    --enable-manager on a Nix-managed env without subprocess errors
  • COMFYUI_MANAGER_DEPENDENCY_MANAGEMENT=off overrides
    dependency_management = on
  • pip list/freeze/show paths still work (UI inventory,
    security check)
  • cm-cli install <node> still installs (CLI not gated)

Notes

Branched off manager-v4 (4.2.1). +46/-1 across two files:
comfyui_manager/common/manager_util.py and
comfyui_manager/prestartup_script.py.

@caniko caniko force-pushed the fix/managed-env-no-auto-install branch 2 times, most recently from 9a35c29 to 1584887 Compare May 4, 2026 13:19
caniko added 2 commits May 4, 2026 15:19
Add a `dependency_management` config key (and matching
`COMFYUI_MANAGER_DEPENDENCY_MANAGEMENT` env override) so installs on
externally-managed Python environments — Nix, Guix, system packages,
locked-down corporate images — can disable every prestartup path that
mutates the interpreter.

When set to `off`:
- `PIPFixer.fix_broken()` returns immediately (no torch/opencv/comfy
  rollback, no `comfyui-frontend-package` reinstall).
- The unified dependency resolver is skipped before it tries to
  `uv pip install` against a read-only store.
- Per-node `pip install -r requirements.txt` in
  `execute_lazy_install_script` is skipped.

Read-only operations (`pip list`, `pip freeze`, `pip show`) still run,
so the UI, inventory, and security checks keep functioning. Default is
`on`, preserving today's behavior for every existing user.
Lift the on/off value parser to `manager_util.is_off_value` so the
prestartup hook and the new tests share one definition, and cover the
flag's contract:

- default is enabled (today's behavior is preserved bit-for-bit)
- PIPFixer.fix_broken short-circuits without spawning subprocess when
  the flag is off
- PIPFixer.fix_broken still reaches subprocess when the flag is on
- make_pip_cmd is not gated — read paths (`pip list`, `freeze`, `show`)
  the UI and security check rely on continue to work
- value parser accepts off/false/0/no/disabled (case- and
  whitespace-insensitive) and treats unknown values as "on" so a typo
  doesn't silently disable installs
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.

1 participant