File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,8 @@ fn get_conda_dir_from_cmd(cmd_line: String) -> Option<PathBuf> {
193193 }
194194 // Sometimes we can have paths like
195195 // # cmd: C:\Users\donja\miniconda3\lib\site-packages\conda\__main__.py create --yes --prefix .conda python=3.9
196+ // # cmd: /Users/donjayamanne/.pyenv/versions/mambaforge-22.11.1-3/lib/python3.10/site-packages/conda/__main__.py create --yes --prefix .conda python=3.12
197+
196198 let mut cmd_line = cmd_line. to_path_buf ( ) ;
197199 if cmd_line
198200 . to_str ( )
@@ -201,10 +203,8 @@ fn get_conda_dir_from_cmd(cmd_line: String) -> Option<PathBuf> {
201203 && cmd_line. to_str ( ) . unwrap_or_default ( ) . contains ( "lib" )
202204 {
203205 loop {
204- if cmd_line
205- . to_str ( )
206- . unwrap_or_default ( )
207- . contains ( "site-packages" )
206+ if cmd_line. to_str ( ) . unwrap_or_default ( ) . contains ( "lib" )
207+ && !cmd_line. to_str ( ) . unwrap_or_default ( ) . ends_with ( "lib" )
208208 {
209209 let _ = cmd_line. pop ( ) ;
210210 } else {
@@ -253,7 +253,6 @@ pub fn get_activation_command(
253253
254254#[ cfg( test) ]
255255mod tests {
256- #[ cfg( windows) ]
257256 use super :: * ;
258257
259258 #[ test]
@@ -276,4 +275,16 @@ mod tests {
276275
277276 assert ! ( conda_dir. is_none( ) ) ;
278277 }
278+
279+ #[ test]
280+ #[ cfg( unix) ]
281+ fn parse_cmd_line ( ) {
282+ let line = "# cmd: /Users/donjayamanne/.pyenv/versions/mambaforge-22.11.1-3/lib/python3.10/site-packages/conda/__main__.py create --yes --prefix .conda python=3.12" ;
283+ let conda_dir = get_conda_dir_from_cmd ( line. to_string ( ) ) . unwrap ( ) ;
284+
285+ assert_eq ! (
286+ conda_dir,
287+ PathBuf :: from( "/Users/donjayamanne/.pyenv/versions/mambaforge-22.11.1-3" )
288+ ) ;
289+ }
279290}
You can’t perform that action at this time.
0 commit comments