From 02c105c3cbc53e291632dc43dbef8777410656c8 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 2 Dec 2024 18:05:32 -0500 Subject: [PATCH] Include base installation directory in uv run PATH (#9585) ## Summary On Windows, non-virtual environments put the `python.exe` in the top-level of the installation directory, rather than in `Scripts`. This PR adds those paths to `PATH` in `uv run` and `uv tool run`. Closes https://github.com/astral-sh/uv/issues/9574#issuecomment-2512217110. --- crates/uv/src/commands/project/run.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index 620db7556..747cddb5b 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -1017,6 +1017,15 @@ pub(crate) async fn run( .map(PythonEnvironment::scripts) .into_iter() .chain(std::iter::once(base_interpreter.scripts())) + .chain( + // On Windows, non-virtual Python distributions put `python.exe` in the top-level + // directory, rather than in the `Scripts` subdirectory. + cfg!(windows) + .then(|| base_interpreter.sys_executable().parent()) + .flatten() + .into_iter(), + ) + .dedup() .map(PathBuf::from) .chain( std::env::var_os(EnvVars::PATH)