necaris / conda.el

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

conda-env-activate doesn't activate base #47

Closed notuntoward closed 4 years ago

notuntoward commented 4 years ago

If I run:

(conda-env-activate "base")

I get the error: "No such conda environment: base"

But I do have a base environment:


conda env list
# conda environments:
#
base                     C:\Users\scott\Anaconda3
base_sg                  C:\Users\scott\Anaconda3\envs\base_sg
stdso                 *  C:\Users\scott\Anaconda3\envs\stdso
                         C:\tools\Anaconda3

Also, as far as I know, there's always a default base.
soedirgo commented 4 years ago

This is because the envs directory doesn't contain the base environment. Instead, it lies in the conda installation path.

You should be able to do (conda-env-activate "..") to achieve what you want.

necaris commented 4 years ago

@dan-delion thanks for the clarification! Since you can conda activate base, however, I think it might warrant adding a special case for this so we're consistent.

arthurcgusmao commented 4 years ago

Hi, I found a bug related to activating the base environment with the abovementioned workaround: the package is not able to deactivate the environment afterward.

This commit fixes it. I would appreciate if you could take a look into it and see if my changes make sense. If they do, I can continue to work towards making the package list base as an option. Thanks!

necaris commented 4 years ago

Please confirm this is still present now that #66 is merged -- would love to be able to close it! Thanks @arthurcgusmao for the PR!

arthurcgusmao commented 4 years ago

@necaris yes, this is still present. However, easier to be fixed now. Gonna tackle it as soon as I have the time. Thank you for this nice package!

My idea is to modify either conda-env-candidates-from-dir or conda-env-candidates to list another option to the user including "base", where the path for base is conda-anaconda-home. That should solve it I believe, though still gotta think of the best way to do this.

Probably it'll also be necessary to modify with conda-env-name-to-dir --- we need to both list the "base" env to the user and then be able to translate it to the correct, abovementioned path.

notuntoward commented 4 years ago

I just updated to the latest conda package on melpa/elpa and now I am seeing this emacs error message:

c:/Users/scott/anaconda3/envs

The line in my .emacs causing it is:

(conda-env-activate "stdso")

But this line has worked for at least the last six months.

And also:

>dir C:\Users\scott\anaconda3\envs\ Volume in drive C has no label. Volume Serial Number is FE63-9685

Directory of C:\Users\scott\anaconda3\envs

07/16/2020 08:55 PM

. 07/16/2020 08:55 PM .. 05/14/2020 05:17 PM 0 .conda_envs_dir_test 08/13/2020 05:28 PM keras 05/14/2020 05:21 PM stdso 1 File(s) 0 bytes 4 Dir(s) 204,586,835,968 bytes free

necaris commented 4 years ago

@notuntoward can you try updating that line to the full path to your conda env, e.g. C:\\Users\\scott\\anaconda3\\envs\\stdso, and confirm if it still works? If so, then perhaps we need to update the fix from #66 .

notuntoward commented 4 years ago

As in:

(conda-env-activate "c:/Users/scott/anaconda3/envs/stdso")

? Doing that, the error message is still:

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

(I see that the cut and paste in my last message omitted a good chunk of the full error text)

But if I go back to the way it was,

(conda-env-activate "stdso")

I can manually run M-x conda-env-activate and get a prompt from emacs, asking me to pick either stdso or keras. But then get an error message when I pick either one.

So somehow, part of conda is getting the path structure right, while another part believes it's wrong. Is this a Linux/Windows thing?

necaris commented 4 years ago

So somehow, part of conda is getting the path structure right, while another part believes it's wrong. Is this a Linux/Windows thing?

I suspect it is -- I'm going to create a new issue, so that we don't confuse the details of this one, and tag you in it. Would you be able to paste the full error message (and anything that appears in your *Messages* buffer) there, to help debug?

I'm afraid I don't have easy access to a Windows environment so I'm not able to test this easily on Windows -- I can confirm it seems to work for me fine on Linux :cry:

arthurcgusmao commented 4 years ago

Hi, @notuntoward sorry for the issue, it likely is something with the differences Windows and Linux have of handling filenames. Unfortunately, I only tested it myself on Linux.

Probably it is something to do with the modifications in the function conda-env-is-valid-path for Windows, done in #66 as @necaris mentioned.

A possible workaround is (conda-env-activate-path "c:/Users/scott/anaconda3/envs/stdso"), can you please try it?

However, we should fix it the proper way even if the above works.