necaris / conda.el

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

conda-get-Path-prefix: Error: executing Command <path-to-env> #104

Closed cakarmustactalone closed 2 years ago

cakarmustactalone commented 2 years ago

I have installed conda for my doom emacs but whenever I try to activate my environement I could not handle this error : conda--get-path-prefix: Error: executing command "/home/user/.conda/bin/conda ..activate "bash" "/home/user/.conda/envs/dataScience/"" produced error code 127

How Can I solve this. That is really necessary for me bcause I use lsp servers on conda , not in system-wide!

Thanks, regards!

cakarmustactalone commented 2 years ago

I have tried these solution:

(custom-set-variables
 '(conda-anaconda-home "/opt/anaconda/"))

(setq conda-env-home-directory (expand-file-name "/home/jaguar/.conda/")
      conda-env-subdirectory "envs")

This time, I can switch to base environment but my other environment which is located at ~/.conda/envs/ is not shown in M-x conda-activate-env

conda 4.10.1 btw.

triccare commented 2 years ago

I have been a long user, under spacemacs. After recently moving from emacs 27.x to 28.1, and updating spacemacs, I have just started having this issue also. The error code returned was just "2".

I'm attempting to hack it. The guess is that the initial environment has somehow changed, since it appears that the relevant section of conda.el has not changed in awhile.

Note: Under MacOS Catalina, Emacs 28.1, conda-20220530.2154, conda 4.13.0

triccare commented 2 years ago

Well, explicitly setting the command executed in conda--get-path-prefix to various things, the ONLY one that does not work is the activate command. conda <anythingelse> works fine. Still punching...

necaris commented 2 years ago

Do you have details on the specific version of conda, as well?

triccare commented 2 years ago

Yes, it is conda 4.13.0.

Note: Though conda is in the path and, as mentioned any other conda command operates, the conda activate reports that the shell has not been initialized. This is fixed by either forcing in the -i option along with whatever the value of shell-comman-switch is, or by changing the command-format-string to something like the following:

source ~/miniconda3/etc/profile.d/conda.sh && conda activate \"%s\"

This would be at this point in conda.el. The above drops the extra arguments to the format statement so only the environment is being passed.

This seems to be connected to similar issues like #23, where conda has changed somehow to break things. I'm not exactly sure how to make the solution more general; the above patch seems to get the job done for me anyways. Hope it helps and if I get a chance to explore further, will try; the day-job is requiring attention.

ltmsyvag commented 2 years ago

I have a laziest fix ever:

 (defun me/conda--get-path-prefix (env-dir)
  (expand-file-name "~/your_conda_folder/envs/your_env_name/bin"))

 (advice-add 'conda--get-path-prefix :override #'me/conda--get-path-prefix)

This works if you only stick to one conda environment, as I do. My OS is Catalina.

necaris commented 2 years ago

Folks who have had this issue -- hopefully the updates in #23 will fix it. Please stay tuned!

ltmsyvag commented 2 years ago

Folks who have had this issue -- hopefully the updates in #23 will fix it. Please stay tuned!

Great! In the meantime I guess the best "fix" is just conda install conda=4.12. Unless you have an unlikely critical dependency on the newest conda 4.13.

necaris commented 2 years ago

As #23 is now merged I'm closing this as fixed, but please reopen if it isn't!