necaris / conda.el

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

Cannot deactivate conda environment #118

Closed cemeroncel closed 2 years ago

cemeroncel commented 2 years ago

Hello,

I am running Emacs 28.1 with native compilation and Conda 4.13. I have two conda environments. The command conda-env-list correctly shows them, and I can also activate them with conda-env-activate. However, when I try to deactivate them using conda-env-deactivate I get the following error:

conda--call-json-subcommand: could not parse JSON stream: "invalid token near 'ArgumentError'", "<string>", 2, 13, 14

I have miniconda instead of anaconda if it is related.

ScottH commented 2 years ago

I'm seeing the same issue on emacs 28.1, miniconda, and I'm on OSX

necaris commented 2 years ago

Could you post the output of the command conda shell.posix+json deactivate $ENVIRONMENT (where $ENVIRONMENT is one of your available environments)?

ScottH commented 2 years ago

OK. Here you go. Thanks! -Scott

(base) @. ~ % conda activate stats (stats) @. ~ % conda shell.posix+json deactivate stats

ArgumentError: deactivate does not accept arguments remainder_args: ['stats']

But I can do this:

(stats) @.*** ~ % conda shell.posix+json deactivate { "path": { "PATH": [ "/Users/scott/miniconda3/bin", "/Users/scott/miniconda3/condabin", "/usr/local/bin", "/usr/bin", "/bin", "/usr/sbin", "/sbin", "/Library/TeX/texbin", "/opt/X11/bin", "/Library/Apple/usr/bin" ] }, "vars": { "export": { "CONDA_PREFIX": "/Users/scott/miniconda3", "CONDA_SHLVL": 1, "CONDA_DEFAULT_ENV": "base", "CONDA_PROMPT_MODIFIER": "(base) ", "CONDA_EXE": "/Users/scott/miniconda3/bin/conda", "_CE_M": "", "_CE_CONDA": "", "CONDA_PYTHON_EXE": "/Users/scott/miniconda3/bin/python" }, "unset": [ "CONDA_PREFIX_1" ], "set": { "PS1": "(base) " } }, "scripts": { "activate": [], "deactivate": [] } }%

On Sat, Jul 9, 2022 at 11:11 AM Rami Chowdhury @.***> wrote:

Could you post the output of the command conda shell.posix+json deactivate $ENVIRONMENT (where $ENVIRONMENT is one of your available environments)?

— Reply to this email directly, view it on GitHub https://github.com/necaris/conda.el/issues/118#issuecomment-1179575777, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABVTB5BYINM7O55IESOMHTVTGXD3ANCNFSM52ZZBEXQ . You are receiving this because you commented.Message ID: <necaris/conda. @.***>

ScottH commented 2 years ago

I've tried the fix where you removed the argument to the deactivate command, but now I get this when I try to deactivate an env.

conda--get-deactivation-parameters: Wrong number of arguments: #[(subcommand env-dir) " ^X

=<83>^M^@Ȃ^N^@^Z^H ^K^L%^]^M!^^^U^N^V\"<83>+^@^N^U!<82>3^@^N^U%,<87>" [conda system-type sh subcommand env-dir cmd conda--get-executable-path windows-nt "cmd.exe" "posix" ...] 6 ("/Users/scott/.emacs.d/elpa/conda-20220710.1740/conda.elc" . 16112)], 1
ScottH commented 2 years ago

conda-call-json-subcommand is expecting that all commands come with env-dir. Maybe make the env-dir an optional argument so the function can handle the deactivate command?

Sorry I'm not terribly fluent in elisp. I really appreciate this package!

(defun conda--call-json-subcommand (subcommand env-dir) ....

ScottH commented 2 years ago

I tried this and it seems to work:

(defun conda--call-json-subcommand (subcommand &optional env-dir) "Call Conda SUBCOMMAND on ENV-DIR returning JSON." (unless env-dir (setq env-dir "")) ....

ScottH commented 1 year ago

I’ll try to dig in and check this tonight once the baby is asleep. Thanks! Scott

Sent from my iPhone

On Jul 9, 2022, at 11:11 AM, Rami Chowdhury @.***> wrote:

 Could you post the output of the command conda shell.posix+json deactivate $ENVIRONMENT (where $ENVIRONMENT is one of your available environments)?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.