necaris / conda.el

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

Unable to activate environment on Windows #68

Closed necaris closed 4 years ago

necaris commented 4 years ago

See https://github.com/necaris/conda.el/issues/47#issuecomment-674576255 from @notuntoward: unable to activate an existing environment using (conda-env-activate "<name>") in .emacs, despite it showing up in the list when running M-x conda-env-activate.

arthurcgusmao commented 4 years ago

Context: @notuntoward is experiencing the following error, on Windows,

Error (use-package): conda/:config: Invalid conda environment path
specified: c:/Users/scott/anaconda3/envs/stdso/

when trying to run

(conda-env-activate "stdso")

That error is raised by the conda-env-activate-path function when the call

(conda-env-is-valid-path "c:/Users/scott/anaconda3/envs/stdso/")

returns nil.

@notuntoward, can you please check that:

  1. The value of conda-env-executables-dir is "Scripts";
  2. The file c:/Users/scott/anaconda3/envs/stdso/Scripts/python.exe exists;
  3. The output of both
    (concat (expand-file-name "c:/Users/scott/anaconda3/envs/stdso/")
                    (file-name-as-directory conda-env-executables-dir)
                    (if (eq system-type 'windows-nt) "python.exe" "python"))

    and

    (concat (file-name-as-directory (expand-file-name "c:/Users/scott/anaconda3/envs/stdso/"))
                    (file-name-as-directory conda-env-executables-dir)
                    (if (eq system-type 'windows-nt) "python.exe" "python"))

    and let us know the results?

notuntoward commented 4 years ago

@arthurcgusmao wrote: can you please check that:

  1. The value of conda-env-executables-dir is "Scripts"; Answer: Yes

  2. The file c:/Users/scott/anaconda3/envs/stdso/Scripts/python.exe exists; Answer: No This must be the problem. python.exe is in: c:/Users/scott/anaconda3/envs/stdso/python.exe

  3. The output of both

output of 1st command: "c:/Users/scott/anaconda3/envs/stdso/Scripts/python.exe"

output of 2nd command: "c:/Users/scott/anaconda3/envs/stdso/Scripts/python.exe"

arthurcgusmao commented 4 years ago

@notuntoward Yes, probably. That function was introduced in 2dce0ac, but it was only being used by the conda-env-activate-path function. My refactoring made conda-env-activate use the former as a subroutine, which revealed the bug.

I have created a fix that should solve the issue.

Can you please give it a try? An easy way to do it is to just evaluate the new file conda.el and try activating an environment. This fix should also make the package list "base" for Windows systems as a valid option.

necaris commented 4 years ago

@notuntoward thank you for the detailed bug report! I hope that @arthurcgusmao's helpful fix in #71 has solved this -- please let us know if that's not the case!

notuntoward commented 4 years ago

@arthurcgusmao and @necaris, Thanks -- both problems are fixed.