Skip to content

Fix Windows fallback after an explicit PATH lookup fails - #749

Open
anticipate218 wants to merge 1 commit into
theskumar:mainfrom
anticipate218:fix/windows-path-lookup-miss
Open

anticipate218 wants to merge 1 commit into
theskumar:mainfrom
anticipate218:fix/windows-path-lookup-miss

Conversation

@anticipate218

Copy link
Copy Markdown

When an explicit effective PATH does not contain the requested command, dotenv run on Windows can still start a copy from the parent process's PATH. After #742, shutil.which returns None for this case, and passing executable=None to Popen enables Windows' independent command search again.

This change reports the existing command-not-found error when lookup fails and the effective environment contains PATH. If PATH is absent from both environments, the existing Windows default search remains available. Explicit executable paths continue to work.

The regression uses a harmless copy of cmd.exe with a unique name in a separate parent-PATH directory. The working directory and the PATH supplied by the .env file do not contain that executable. Two additional cases preserve execution without PATH, using both a bare system command and its absolute path.

Validation on Windows / CPython 3.13.5 against base 4fbc6ff:

  • Before the fix, the new regression starts the parent-PATH command unexpectedly: 1 failed, 240 passed, 52 skipped.
  • Final full pytest run with coverage: 243 passed, 52 skipped.
  • Ruff 0.12.0 check and format checks pass for all src and tests files.
  • Mypy passes for Python targets 3.10 through 3.15 with the Linux platform target used by the lint CI job. Native Windows type checks report the unchanged os.mkfifo attribute error in tests/test_fifo_dotenv.py; the exact unmodified source snapshot reports the same error with the Python 3.13 static target.
  • check-manifest 0.51 passes.
  • Additional native process probes cover an empty PATH, an excluding PATH, an including PATH, inherited PATH, --no-override, relative and absolute executable paths, and a completely absent PATH.

The full cross-platform Python runtime matrix was not run locally. This does not change PATHEXT handling.

AI disclosure: Prepared with OpenAI Codex, including independent agent review and the local validation described above.

Report command-not-found when Windows cannot resolve a command in the effective PATH. Preserve default Windows search when PATH is absent and add real subprocess regression coverage.

Assisted-by: OpenAI Codex

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.

1 participant