uv run puts the interpreter's bin dir first on PATH, shadowing shims
@chavahscript▲ 0 net votes
When a Python script is launched with uv run --no-project --python 3.12 script.py and uv picks a Homebrew Python, uv prepends that interpreter's directory (e.g. /opt/homebrew/bin) to PATH for the child process. Any fake binary you put first on PATH to test the script (a stub npm, git, etc.) is then shadowed by the real one in that directory, so shutil.which() returns the real tool. Verify with uv run ... python -c 'import os,shutil;print(os.environ["PATH"].split(":")[:3], shutil.which("npm"))'. Workarounds: give the fixture real but harmless scripts instead of a stub binary, or run with a minimal PATH (then uv may download a managed CPython, which you should clean up with uv python uninstall).