Fix dependency resolution to prevent using global Python site-packages#3134
Merged
joeyballentine merged 2 commits intomainfrom Oct 20, 2025
Merged
Fix dependency resolution to prevent using global Python site-packages#3134joeyballentine merged 2 commits intomainfrom
joeyballentine merged 2 commits intomainfrom
Conversation
joeyballentine
approved these changes
Oct 19, 2025
Copilot
AI
changed the title
[WIP] Fix chaiNNer dependency resolution using global site-packages
Fix dependency resolution to prevent using global Python site-packages
Oct 19, 2025
Co-authored-by: joeyballentine <34788790+joeyballentine@users.noreply.github.com>
bd66eb8 to
867e625
Compare
joeyballentine
approved these changes
Oct 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ChaiNNer was erroneously resolving dependencies from global Python site-packages (particularly user site-packages like
C:\Users\...\AppData\Roaming\Python\Python311\site-packageson Windows or~/.local/lib/python3.X/site-packageson Linux) instead of using its own isolated environment.This caused pip to skip installing packages in chaiNNer's venv when they were already present in the user's global site-packages, leading to:
The issue was particularly problematic for portable installations where users had existing Python environments with different package versions.
Root Cause
Python by default enables user site-packages lookup (via
site.ENABLE_USER_SITE), and subprocess environments inherited all environment variables from the parent process. When pip ran to install dependencies, it would:Solution
Set the
PYTHONNOUSERSITE=1environment variable in all Python subprocess calls to disable Python's user site-packages lookup. This ensures pip only sees and uses packages from chaiNNer's isolated environment.Changes
src/main/env.ts- AddedPYTHONNOUSERSITE=1to thesanitizedEnvused by all backend processesbackend/src/dependencies/store.py- AddedPYTHONNOUSERSITE=1to theENVdictionary used by pip install/uninstall operationsbackend/src/dependencies/install_server_deps.py- Updated to import and useENVfromstore.pyfor thepip listcommandTesting
PYTHONNOUSERSITE=1correctly disables user site-packagesImpact
This fix ensures chaiNNer's portable installation will:
Fixes #2962 (related issue)
Original prompt
Fixes #3010
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.