necaris / conda.el

Emacs helper library (and minor mode) to work with conda environments
MIT License
153 stars 49 forks source link

`conda--get-deactivation-parameters` would error with missing arguments #121

Closed shrubbroom closed 2 years ago

shrubbroom commented 2 years ago

Emacs verison: 28.1 mac-port with native-comp Minimal configuration

(package-initialize)
(require 'conda)
(custom-set-variables
   '(conda-anaconda-home "/opt/miniconda3"))

Then use conda-env-deactivate to deactivate base. The emacs would error with

(wrong-number-of-arguments #<subr conda--call-json-subcommand> 1)

Tune the function conda--call-json-subcommand a bit would help.

https://github.com/necaris/conda.el/blob/06a1ac946ed245e0b0fae2755f9641c4c180de9f/conda.el#L258-L266

(defun conda--call-json-subcommand (subcommand &optional env-dir)
  "Call Conda SUBCOMMAND on ENV-DIR returning JSON."
  (let* ((conda (conda--get-executable-path))
         (sh (if (eq system-type 'windows-nt) "cmd.exe" "posix"))
         (cmd (format "%s shell.%s+json %s %s" conda sh subcommand (or env-dir "")))
         (output (shell-command-to-string cmd)))
    (if (version< emacs-version "27.1")
        (json-read-from-string output)
      (json-parse-string output :object-type 'alist :null-object nil))))

PTAL

necaris commented 2 years ago

Looks like this is the same as #118, which I'll reopen instead