Skip to content

fix: restore Windows DLL search paths after failed loads - #2425

Open
remote-controlled-man wants to merge 2 commits into
abetlen:mainfrom
remote-controlled-man:codex/prflow-eec6ece793a3
Open

remote-controlled-man wants to merge 2 commits into
abetlen:mainfrom
remote-controlled-man:codex/prflow-eec6ece793a3

Conversation

@remote-controlled-man

Copy link
Copy Markdown

Fixes #2424.

Failed Windows library loads leave an extra library-directory entry in PATH and unclosed DLL search-directory registrations, so retrying an unavailable installation keeps changing process state.

Roll back changes made by an unsuccessful load, including a missing library or a failure partway through CUDA/HIP directory registration.
Register the library directory once per attempt and avoid prepending a duplicate PATH entry.
Keep dependency search paths after a successful load, and preserve earlier successful registrations when a later load fails.

Add regression tests for retries, CUDA/HIP paths, partial setup, missing libraries, absent/empty/existing PATH, successful loads and non-Windows controls.

Validation on macOS 26.7.3 arm64, Python 3.12.14, using the pinned native llama.cpp build (Metal and CPU support):

  • With the original loader, the same 18 cases produce 15 failures and 3 passing platform controls; the fixed loader passes all 18.
  • Full make test: 44 passed, including the real-model tests.
  • Full make lint: Ruff checks and all 30 Python files pass the format check.
  • A real ctypes.CDLL failure repeated three times also leaves PATH unchanged with the fix; the original adds three entries.

The Windows regression tests replace the platform APIs at the loader boundary.
An actual Windows DLL integration run has not been performed locally.

Copilot AI balanced review requested due to automatic review settings November 21, 2026 04:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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.

Windows: every failed import llama_cpp prepends to PATH and adds DLL directories again

2 participants