Set VIRTUAL_ENV for uv run invocations (#6543)

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.
This commit is contained in:
Zanie Blue
2024-08-23 15:03:38 -05:00
committed by GitHub
parent 9d1cd8e48c
commit 80b5384a4d
+5
View File
@@ -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