Skip to content

Commit

Permalink
Set VIRTUAL_ENV for uv run invocations (#6543)
Browse files Browse the repository at this point in the history
If we don't do this, and `uv run` invokes something like `uv run
--isolated uv pip install foo` uv won't mutate the isolated environment,
it'll mutate whatever outer environment it finds.
  • Loading branch information
zanieb authored Aug 23, 2024
1 parent 9d1cd8e commit 80b5384
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/uv/src/commands/project/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,11 @@ pub(crate) async fn run(
)?;
process.env("PATH", new_path);

// Ensure `VIRTUAL_ENV` is set.
if interpreter.is_virtualenv() {
process.env("VIRTUAL_ENV", interpreter.sys_prefix().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
Expand Down

0 comments on commit 80b5384

Please sign in to comment.