Skip to content

Commit 5e72a66

Browse files
committed
fix: Handle nonexistence of conda-home-candidates
Borrowed from Doom Emacs' fix in doomemacs/doomemacs@8f60a1b
1 parent ce748a5 commit 5e72a66

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

conda.el

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,35 @@
3131
:group 'python)
3232

3333
(defcustom conda-home-candidates
34-
'("~/.anaconda3" "~/miniconda3" "~/mambaforge" "~/anaconda" "~/miniconda" "~/mamba" "~/.conda")
34+
(list "~/.anaconda"
35+
"~/.anaconda3"
36+
"~/.miniconda"
37+
"~/.miniconda3"
38+
"~/.miniforge3"
39+
"~/.mambaforge"
40+
"~/anaconda3"
41+
"~/miniconda3"
42+
"~/miniforge3"
43+
"~/mambaforge"
44+
"~/opt/miniconda3"
45+
"/opt/miniconda3"
46+
"/usr/bin/anaconda3"
47+
"/usr/local/anaconda3"
48+
"/usr/local/miniconda3"
49+
"/usr/local/Caskroom/miniconda/base"
50+
"~/.conda")
3551
"Location of possible candidates for conda environment directory."
3652
:type '(list string)
3753
:group 'conda)
3854

3955
;; TODO: find some way to replace this with `(alist-get 'root_prefix (conda--get-config))`
4056
;; unfortunately right now (conda--get-executable-path) relies on this!
4157
(defcustom conda-anaconda-home
42-
(expand-file-name (or (getenv "ANACONDA_HOME")
43-
(catch 'conda-catched-home
44-
(dolist (candidate conda-home-candidates)
45-
(when (f-dir? (expand-file-name candidate))
46-
(throw 'conda-catched-home candidate))))))
58+
(or (cl-loop for dir in (cons (getenv "ANACONDA_HOME") conda-home-candidates)
59+
if (and dir (file-directory-p dir))
60+
return (setq conda-anaconda-home (expand-file-name dir)
61+
conda-env-home-directory (expand-file-name dir)))
62+
(message "Cannot find Anaconda installation"))
4763
"Location of your conda installation.
4864
4965
Iterate over default locations in CONDA-HOME-CANDIDATES, or read from the
@@ -686,3 +702,4 @@ buffer."
686702
(provide 'conda)
687703

688704
;;; conda.el ends here
705+

0 commit comments

Comments
 (0)