From 3483962a9e0157a3ad4a6f665ababdc0821e2bb5 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Wed, 8 May 2024 13:50:08 +1000 Subject: [PATCH] Strip 'envs' prefix from conda env name --- native_locator/src/conda.rs | 2 +- native_locator/tests/conda_test.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/native_locator/src/conda.rs b/native_locator/src/conda.rs index a058a7d13ef1..35dee6dc5cac 100644 --- a/native_locator/src/conda.rs +++ b/native_locator/src/conda.rs @@ -338,7 +338,7 @@ fn get_distinct_conda_envs( let mut named = false; let mut name = "".to_string(); for location in &locations { - let location = Path::new(location); + let location = Path::new(location).join("envs"); match env.strip_prefix(location) { Ok(prefix) => { named = true; diff --git a/native_locator/tests/conda_test.rs b/native_locator/tests/conda_test.rs index 3adf8e334948..54f16eef4f5b 100644 --- a/native_locator/tests/conda_test.rs +++ b/native_locator/tests/conda_test.rs @@ -81,8 +81,8 @@ fn finds_two_conda_envs_from_txt() { let conda_2_exe = join_test_paths(&[conda_2.clone().as_str(), "python"]); let expected_conda_env = json!({"executablePath":[conda_exe.clone()],"version":null}); - let expected_conda_1 = json!({"name":"envs/one","pythonExecutablePath":[conda_1_exe.clone()],"category":"conda","version":"10.0.1","activatedRun":[conda_exe.clone(),"run","-n","envs/one","python"],"envPath":conda_1.clone(), "sysPrefixPath":conda_1.clone()}); - let expected_conda_2 = json!({"name":"envs/two","pythonExecutablePath":[conda_2_exe.clone()],"category":"conda","version":null,"activatedRun":[conda_exe.clone(),"run","-n","envs/two","python"],"envPath":conda_2.clone(), "sysPrefixPath":conda_2.clone()}); + let expected_conda_1 = json!({"name":"one","pythonExecutablePath":[conda_1_exe.clone()],"category":"conda","version":"10.0.1","activatedRun":[conda_exe.clone(),"run","-n","one","python"],"envPath":conda_1.clone(), "sysPrefixPath":conda_1.clone()}); + let expected_conda_2 = json!({"name":"two","pythonExecutablePath":[conda_2_exe.clone()],"category":"conda","version":null,"activatedRun":[conda_exe.clone(),"run","-n","two","python"],"envPath":conda_2.clone(), "sysPrefixPath":conda_2.clone()}); assert_messages( &[expected_conda_env, expected_conda_1, expected_conda_2], &dispatcher,