Skip to content

fix: Preserve portable Python isolation on restart#13945

Open
Tom-M-Git wants to merge 27 commits into
Comfy-Org:masterfrom
Tom-M-Git:better-isolation
Open

fix: Preserve portable Python isolation on restart#13945
Tom-M-Git wants to merge 27 commits into
Comfy-Org:masterfrom
Tom-M-Git:better-isolation

Conversation

@Tom-M-Git
Copy link
Copy Markdown

Summary

Preserve portable Python isolation by resetting Python-related environment variables and launching Python with -s.

Current issue

The Windows portable build may unintentionally import packages from the user's Python environment (for example %APPDATA%\Python\Python313\site-packages) during Manager restarts or custom node installation.

This can lead to mixed package resolution between the embedded Python environment and user-site packages, causing issues such as mismatched Torch/Torchaudio installations and inconsistent dependency behavior.

Result

The portable build remains isolated from user-site Python packages across startup and Manager-triggered restarts.

Tom-M-Git added 8 commits May 18, 2026 03:14
Set environment variables for user profile and cache paths.
Set environment variables for user profile and cache paths before running the Python script.
Set environment variables for user profile and cache directories before running the Python script.
Set environment variables for user profile and cache paths before executing the Python script.
Set environment variables for user profile and cache paths before running the Python script.
@Tom-M-Git
Copy link
Copy Markdown
Author

Updated. Removed cache dir reset code and made code more consistent.

Reason:

  • It changes storage behavior beyond Python isolation.
  • It may dump many GB of model/cache files into the ComfyUI folder.

@Tom-M-Git
Copy link
Copy Markdown
Author

Updated. Fixed unused variable.

@alexisrolland
Copy link
Copy Markdown
Member

Tested for the following .bat files and it works fine:

  • advanced/run_nvidia_gpu_disable_api_nodes.bat
  • windows_nvidia_base_files/run_cpu.bat
  • windows_nvidia_base_files/run_nvidia_gpu.bat

alexisrolland
alexisrolland previously approved these changes May 28, 2026
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.

3 participants