Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Windows path to conda.exe after #57 #59

Closed
notuntoward opened this issue May 15, 2020 · 6 comments
Closed

Incorrect Windows path to conda.exe after #57 #59

notuntoward opened this issue May 15, 2020 · 6 comments

Comments

@notuntoward
Copy link

notuntoward commented May 15, 2020

On my Windows machine, Anaconda has installed conda.exe in:

c:/Users/scott/anaconda3/Scripts/conda.exe

but since #57, the conda package looks for it in:

c:/Users/scott/anaconda3/bin/conda

Or so it seems, if I look at the error message emacs gives me when I try to activate an environment named "stdso":

Error (use-package): conda/:config: Error: executing command
"c:/Users/scott/anaconda3/bin/conda ..activate "cmd.exe"
c:/Users/scott/anaconda3/envs/stdso" produced error code 1

Before #57, I think that the conda package looked in my PATH environment variable for a conda.exe, which worked correctly.

I have set both conda-env-home-directory and conda-anaconda-home to:

c:/Users/scott/anaconda3

@Shiandow
Copy link
Contributor

I think this is because of some recent changes to conda--get-path-prefix. In particular it was made to default to the 'bin' folder even on windows.

On my end I've managed to fix it by overriding the function to use the conda-env-executables-dir which does list the correct path, and to use quoted paths (just in case there is a space in there somwhere). You can try it out by adding the following to your .emacs somewhere:

(with-eval-after-load 'conda
    (defun conda--get-path-prefix (env-dir)
    "Get a platform-specific path string to utilize the conda env in ENV-DIR.
It's platform specific in that it uses the platform's native path separator."
    (s-trim
     (with-output-to-string
       (with-current-buffer standard-output
         (let* ((conda-executable-path
                 (concat (file-name-as-directory conda-anaconda-home) (file-name-as-directory conda-env-executables-dir) "conda"))
                (command "\"%s\" ..activate \"%s\" \"%s\"")
                (formatted-command (format command
                                           conda-executable-path
                                           (if (eq system-type 'windows-nt)
                                               "cmd.exe"
                                             "bash")
                                           env-dir))
                (return-code (process-file shell-file-name nil '(t nil) nil shell-command-switch formatted-command)))
           (unless (= 0 return-code)
             (error (format "Error: executing command \"%s\" produced error code %d" formatted-command return-code)))))))))

I've made a pull request #60 with these changes.

@notuntoward
Copy link
Author

Thanks! I'll give it a try as soon as it ends up on melpa.

@notuntoward
Copy link
Author

@necaris and @Shiandow: This is to confirm that @Shiandow's fix works for me. Anything else needed to get #60 into melpa?

@necaris
Copy link
Owner

necaris commented Jun 22, 2020

Closed by #60

@necaris necaris closed this as completed Jun 22, 2020
@necaris
Copy link
Owner

necaris commented Jun 22, 2020

@notuntoward can you confirm if the latest version on Melpa (which I've confirmed matches the most recent commit to master) works for you? This should include #60

@notuntoward
Copy link
Author

Yes, it works for me. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants