Skip to content

Commit

Permalink
Include base installation directory in uv run PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Dec 2, 2024
1 parent ff91cf7 commit 6ca9e03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 8 additions & 0 deletions crates/uv/src/commands/project/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,15 @@ pub(crate) async fn run(
.as_ref()
.map(PythonEnvironment::scripts)
.into_iter()
.chain(
ephemeral_env
.as_ref()
.and_then(|env| env.python_executable().parent())
.into_iter(),
)
.chain(std::iter::once(base_interpreter.scripts()))
.chain(base_interpreter.sys_executable().parent().into_iter())
.dedup()
.map(PathBuf::from)
.chain(
std::env::var_os(EnvVars::PATH)
Expand Down
16 changes: 10 additions & 6 deletions crates/uv/src/commands/tool/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,16 @@ pub(crate) async fn run(

// Construct the `PATH` environment variable.
let new_path = std::env::join_paths(
std::iter::once(environment.scripts().to_path_buf()).chain(
std::env::var_os(EnvVars::PATH)
.as_ref()
.iter()
.flat_map(std::env::split_paths),
),
std::iter::once(environment.scripts())
.chain(environment.python_executable().parent().into_iter())
.dedup()
.map(PathBuf::from)
.chain(
std::env::var_os(EnvVars::PATH)
.as_ref()
.iter()
.flat_map(std::env::split_paths),
),
)?;
process.env(EnvVars::PATH, new_path);

Expand Down

0 comments on commit 6ca9e03

Please sign in to comment.