vim-conda
vim-conda copied to clipboard
how to set CONDA_EXE on MS Windows?
where and how exactly should I set this variable on windows
I have already tried: C:\Users\adrian\Miniconda3\Scripts\conda.exe /c/Users/adrian/Miniconda3/Scripts/conda.exe
in System Properieties > Environment Variables
and in neovim running :echo $CONDA_EXE it shows the set path
but when I try :CondaChangeEnv I still get:
RuntimeError: $CONDA_EXE is not set to a valid conda executable ($CONDA_EXE='$CONDA_EXE')
I looked into the coda and I tried to come up with mimal example, here output from Window cmd terminal:
C:\Users\adrian>echo %CONDA_EXE%
C:\Users\adrian\Miniconda3\Scripts\conda.exe
C:\Users\adrian>type z.py
from subprocess import check_output, CalledProcessError, PIPE
import json
import os
def vim_conda_runshell(cmd):
""" Run external shell command """
return check_output(cmd, shell=True, executable=os.getenv('SHELL'), stdin=PIPE, stderr=PIPE).decode('utf-8')
try:
output = vim_conda_runshell('$CONDA_EXE info --json')
print(json.loads(output))
except CalledProcessError:
cmd = vim_conda_runshell('echo $CONDA_EXE').strip()
raise RuntimeError("$CONDA_EXE is not set to a valid conda executable ($CONDA_EXE='{}')".format(cmd)) from None
C:\Users\adrian>python z.py
Traceback (most recent call last):
File "C:\Users\320138242\z.py", line 15, in <module>
raise RuntimeError("$CONDA_EXE is not set to a valid conda executable ($CONDA_EXE='{}')".format(cmd)) from None
RuntimeError: $CONDA_EXE is not set to a valid conda executable ($CONDA_EXE='$CONDA_EXE')
So it seems that it about the difference between syntax of using %CONDA_EXE%
vs $CONDA_EXE
.
On the other hand if I try the same thing inside Git Bash terminal, I get:
adrian@adriansmachine MINGW64 ~
$ echo $CONDA_EXE
/c/Users/adrian/Miniconda3/Scripts/conda.exe
(base)
adrian@adriansmachine MINGW64 ~
$ python z.py
Traceback (most recent call last):
File "C:\Users\adrian\z.py", line 11, in <module>
output = vim_conda_runshell('$CONDA_EXE info --json')
File "C:\Users\adrian\z.py", line 8, in vim_conda_runshell
return check_output(cmd, shell=True, executable=os.getenv('SHELL'), stdin=PIPE, stderr=PIPE).decode('utf-8')
File "C:\Users\adrian\Miniconda3\lib\subprocess.py", line 420, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "C:\Users\adrian\Miniconda3\lib\subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '$CONDA_EXE info --json' returned non-zero exit status 126.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\adrian\z.py", line 14, in <module>
cmd = vim_conda_runshell('echo $CONDA_EXE').strip()
File "C:\Users\adrian\z.py", line 8, in vim_conda_runshell
return check_output(cmd, shell=True, executable=os.getenv('SHELL'), stdin=PIPE, stderr=PIPE).decode('utf-8')
File "C:\Users\adrian\Miniconda3\lib\subprocess.py", line 420, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "C:\Users\adrian\Miniconda3\lib\subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'echo $CONDA_EXE' returned non-zero exit status 126.
(base)
I've added a pull request (#40) that fixed this for me, by using os.getenv rather than directly referencing $CONDA_EXE.