From b56af58f7a4cdc0936aa61e9e2a8cb230a1cbac1 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Fri, 23 Aug 2024 14:48:37 -0500 Subject: [PATCH] Set `VIRTUAL_ENV` for `uv run` invocations in ephemeral environments --- crates/uv/src/commands/project/run.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index 38964b63e04b3..a0c0eac4f203c 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -629,6 +629,10 @@ pub(crate) async fn run( )?; process.env("PATH", new_path); + if let Some(env) = ephemeral_env { + process.env("VIRTUAL_ENV", env.root().as_os_str()); + } + // Spawn and wait for completion // Standard input, output, and error streams are all inherited // TODO(zanieb): Throw a nicer error message if the command is not found