File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -191,10 +191,19 @@ fn get_conda_env_name(
191191 // if the conda install folder is parent of the env folder, then we can use named activation.
192192 // E.g. conda env is = <conda install>/envs/<env name>
193193 // Then we can use `<conda install>/bin/conda activate -n <env name>`
194- if let Some ( conda_dir) = conda_dir {
195- if !prefix. starts_with ( conda_dir) {
196- name = get_conda_env_name_from_history_file ( env_path, prefix) ;
197- }
194+ //
195+ // Check the history file when:
196+ // 1. conda_dir is known but prefix is not under it (external environment)
197+ // 2. conda_dir is unknown (we need to check history to determine if it's name or path based)
198+ // This ensures path-based environments (created with --prefix) return None for name,
199+ // so activation uses the full path instead of incorrectly trying name-based activation.
200+ let should_check_history = match conda_dir {
201+ Some ( dir) => !prefix. starts_with ( dir) ,
202+ None => true ,
203+ } ;
204+
205+ if should_check_history {
206+ name = get_conda_env_name_from_history_file ( env_path, prefix) ;
198207 }
199208
200209 name
You can’t perform that action at this time.
0 commit comments