@@ -136,6 +136,15 @@ pub fn get_conda_installation_used_to_create_conda_env(env_path: &Path) -> Optio
136136 if let Some ( conda_dir) = get_conda_dir_from_cmd ( line) {
137137 if is_conda_install ( & conda_dir) {
138138 return Some ( conda_dir) ;
139+ } else {
140+ // Possible this is a directory such as `C:\Users\donja\miniconda3\Scripts`
141+ // We try to remove `Scripts` or `bin` from the path in the `get_conda_dir_from_cmd`.
142+ // However if there are other directories such as `condabin` or others we are not aware of, lets try.
143+ if let Some ( conda_dir) = conda_dir. parent ( ) {
144+ if is_conda_install ( & conda_dir) {
145+ return Some ( conda_dir. into ( ) ) ;
146+ }
147+ }
139148 }
140149 }
141150 }
@@ -233,6 +242,7 @@ fn get_conda_dir_from_cmd(cmd_line: String) -> Option<PathBuf> {
233242 if let Some ( conda_dir) = cmd_line. file_name ( ) {
234243 if conda_dir. to_string_lossy ( ) . to_lowercase ( ) == "bin"
235244 || conda_dir. to_string_lossy ( ) . to_lowercase ( ) == "scripts"
245+ || conda_dir. to_string_lossy ( ) . to_lowercase ( ) == "condabin"
236246 {
237247 if let Some ( conda_dir) = cmd_line. parent ( ) {
238248 // Ensure the casing of the paths are correct.
@@ -285,7 +295,7 @@ fn is_conda_env_name_in_cmd(cmd_line: String, name: &str) -> bool {
285295 // # cmd: /Users/donjayamanne/miniconda3/bin/conda create -n conda1
286296 // # cmd_line: "# cmd: /usr/bin/conda create -p ./prefix-envs/.conda1 python=3.12 -y"
287297 // Look for "-n <name>" in the command line
288- cmd_line. contains ( format ! ( "-n {:? }" , name) . as_str ( ) )
298+ cmd_line. contains ( format ! ( "-n {}" , name) . as_str ( ) )
289299}
290300
291301pub fn get_activation_command (
0 commit comments