diff --git a/nox/virtualenv.py b/nox/virtualenv.py index 28ca5f29..910c6229 100644 --- a/nox/virtualenv.py +++ b/nox/virtualenv.py @@ -45,9 +45,15 @@ def find_uv() -> tuple[bool, str]: + uv_on_path = shutil.which("uv") + # Look for uv in Nox's environment, to handle `pipx install nox[uv]`. with contextlib.suppress(ImportError, FileNotFoundError): from uv import find_uv_bin + uv_bin = find_uv_bin() + + if uv_on_path and Path(uv_bin).samefile(uv_on_path): + return True, "uv" return True, find_uv_bin() @@ -55,7 +61,7 @@ def find_uv() -> tuple[bool, str]: if shutil.which("uv") is not None: return True, "uv" - return False, "uv" + return uv_on_path is not None, "uv" HAS_UV, UV = find_uv()