necaris / conda.el

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

conda-env-activate-for-buffer sets PATH to "", causing "ls" "git" "bash" to fail #145

Open guicho271828 opened 1 year ago

guicho271828 commented 1 year ago

After activating a conda env, emacs starts failing to resolve external program, such as git or ls, in exchange to giving me the ability to M-. into the libraries in the environment.

Before activating the environment: Result of M-: (getenv "PATH") Screenshot from 2023-04-06 16-56-12

After: Result of M-: (getenv "PATH") Screenshot from 2023-04-06 16-56-31

Magit fails Screenshot from 2023-04-06 16-57-44

Dired fails Screenshot from 2023-04-06 17-02-52

Can't run anything from shell-mode buffer Screenshot from 2023-04-06 16-59-46

I worried about my config-vars but this does not show anything suspicious Screenshot from 2023-04-06 17-06-45

necaris commented 1 year ago

Hi -- can you confirm what the behavior is:

guicho271828 commented 1 year ago

Let me add a few more environment info:

[masataro ~]$ conda activate pypergame
WARNING: overwriting environment variables set in the machine
overwriting variable {'PKG_CONFIG_PATH', 'LD_LIBRARY_PATH', 'CPATH'}
(pypergame) [masataro ~]$ conda deactivate
[masataro ~]$ conda -V
conda 23.3.1
[masataro ~]$ uname -a
Linux fedora32-T46 6.1.14-100.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Feb 26 00:31:11 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
[masataro ~]$ emacs --version
GNU Emacs 28.2
Copyright (C) 2022 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
[masataro ~]$ env
SHELL=/bin/bash
IMSETTINGS_INTEGRATE_DESKTOP=yes
SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/1929130,unix/unix:/tmp/.ICE-unix/1929130
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1
HISTCONTROL=ignoreboth
MPI_LIB=/usr/lib64/mpich/lib
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GTK_IM_MODULE=fcitx
CONDA_EXE=/home/masataro/miniconda3/bin/conda
_CE_M=
PKG_CONFIG_PATH=/usr/lib64/mpich/lib/pkgconfig
HOSTNAME=fedora32-T46
HISTSIZE=1000
TERMCAP=
SSH_AUTH_SOCK=/tmp/ssh-XXXXXXAhSnMu/agent.1929130
HOSTALIASES=/home/masataro/.hostaliases
__MODULES_SHARE_LD_LIBRARY_PATH=:1
INPUT_METHOD=fcitx
INSIDE_EMACS=28.2,comint
XMODIFIERS=@im=fcitx
DESKTOP_SESSION=cinnamon
SSH_AGENT_PID=1929257
EDITOR=emacs
XDG_SEAT=seat0
PWD=/home/masataro
LOGNAME=masataro
XDG_SESSION_DESKTOP=cinnamon
QT_QPA_PLATFORMTHEME=gtk2
XDG_SESSION_TYPE=x11
MODULESHOME=/usr/share/Modules
MANPATH=/usr/share/man/mpich-x86_64:/usr/share/man:/home/masataro/.local/share/man/man1:
MPI_COMPILER=mpich-x86_64
MPI_PYTHON2_SITEARCH=%{python2_sitearch}/mpich
MPI_INCLUDE=/usr/include/mpich-x86_64
CUDA_INCLUDE_DIRS=/usr/include
XAUTHORITY=/run/lightdm/masataro/xauthority
FOAM_TUTORIALS=/usr/share/doc/openfoam-examples/examples
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/masataro
MPI_FORTRAN_MOD_DIR=/usr/lib64/gfortran/modules/mpich
MPI_HOME=/usr/lib64/mpich
__MODULES_SHARE_MANPATH=:2
HOME=/home/masataro
LANG=ja_JP.UTF-8
LS_COLORS=
XDG_CURRENT_DESKTOP=X-Cinnamon
__MODULES_LMCONFLICT=mpi/mpich-x86_64&mpi
COLUMNS=118
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
CUDA_INC_PATH=/usr/include
MPI_SYSCONFIG=/etc/mpich-x86_64
IMSETTINGS_MODULE=fcitx5
MOZ_GMP_PATH=/usr/lib64/mozilla/plugins/gmp-gmpopenh264/system-installed
MPI_SUFFIX=_mpich
XDG_SESSION_CLASS=user
MAKEFLAGS=-j 16
TERM=dumb
_CE_CONDA=
GTK_OVERLAY_SCROLLING=0
LESSOPEN=||/usr/bin/lesspipe.sh %s
USER=masataro
CUDA_ROOT=/usr
MPI_PYTHON_SITEARCH=%{python2_sitearch}/mpich
CONDA_SHLVL=0
MODULES_RUN_QUARANTINE=LD_LIBRARY_PATH LD_PRELOAD
PAM_KWALLET5_LOGIN=/run/user/1000/kwallet5.socket
LOADEDMODULES=mpi/mpich-x86_64
DISPLAY=:0
SHLVL=2
MPI_BIN=/usr/lib64/mpich/bin
QT_IM_MODULE=fcitx
XDG_VTNR=1
DESKTOP_AUTOSTART_ID=105fc95c0f2af207b4168081447244073000019291300017
XDG_SESSION_ID=5
CONDA_PYTHON_EXE=/home/masataro/miniconda3/bin/python
LD_LIBRARY_PATH=/usr/lib64/mpich/lib:/home/masataro/.local/lib:/usr/lib64/:
XDG_RUNTIME_DIR=/run/user/1000
S_COLORS=auto
MPI_PYTHON3_SITEARCH=/usr/lib64/python3.10/site-packages/mpich
DEBUGINFOD_URLS=https://debuginfod.fedoraproject.org/ 
MPI_MAN=/usr/share/man/mpich-x86_64
which_declare=declare -f
KDEDIRS=/usr
GTK3_MODULES=xapp-gtk3-module
XDG_DATA_DIRS=/home/masataro/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
PATH=/usr/lib64/mpich/bin:/usr/share/Modules/bin:/usr/lib64/ccache:/home/masataro/.local/texlive/2019/bin/x86_64-linux:/home/masataro/.roswell/bin:/home/masataro/.local/bin:/home/masataro/bin:/home/masataro/miniconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin
MODULEPATH=/usr/share/Modules/modulefiles:/etc/modulefiles:/usr/share/modulefiles
GDMSESSION=cinnamon
_LMFILES_=/usr/share/modulefiles/mpi/mpich-x86_64
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
MAIL=/var/spool/mail/masataro
CPATH=/home/masataro/.local/include:/usr/include/:
GIO_LAUNCHED_DESKTOP_FILE_PID=2496497
GIO_LAUNCHED_DESKTOP_FILE=/usr/share/applications/emacs.desktop
MODULES_CMD=/usr/share/Modules/libexec/modulecmd.tcl
BASH_FUNC_ml%%=() {  module ml "$@"
}
BASH_FUNC_which%%=() {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@
}
BASH_FUNC_module%%=() {  eval `/usr/bin/tclsh /usr/share/Modules/libexec/modulecmd.tcl bash "$@"`;
 _mlstatus=$?;
 return $_mlstatus
}
BASH_FUNC_bell%%=() {  if [[ $? == 0 ]]; then
 $HOME/.local/bin/bell -s "$@";
 else
 $HOME/.local/bin/bell -f "$@";
 fi
}
_=/usr/bin/env
[masataro ~]$ 

Code that initializes conda in .bashrc:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('$HOME/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "$HOME/miniconda3/etc/profile.d/conda.sh" ]; then
        . "$HOME/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="$HOME/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
guicho271828 commented 1 year ago

Hmm, when I create a new environment without conda env config vars set, the issue does not occur.

necaris commented 1 year ago

Can you show the conda env config vars you have set?

guicho271828 commented 1 year ago
    conda env config vars set LD_LIBRARY_PATH=
    conda env config vars set PYTHONPATH=
    conda env config vars set PKG_CONFIG_PATH=
    conda env config vars set PYTHONHASHSEED=30294 # set for reproducibility:

    # these are required for building dependencies properly under conda
    conda env config vars set CPATH=${CONDA_PREFIX}/include:${CONDA_PREFIX}/x86_64-conda-linux-gnu/sysroot/usr/include:
espentrydal commented 8 months ago

@necaris I have the same problem. This happens not on the first run but if I run (conda-env activate "environment") twice in the same buffer. I use org-babel, so sometimes, if I want to rerun the whole buffer, this function in an elisp code block will run twice.

necaris commented 8 months ago

@espentrydal Does this behave the same as @guicho271828 above -- can you try the same debugging steps?

espentrydal commented 8 months ago

@espentrydal Does this behave the same as @guicho271828 above -- can you try the same debugging steps?

@necaris Thank you for your swift reply. Sure:

From .zshrc

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/espen/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/espen/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/home/espen/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/espen/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
$ cond env list
# conda environments:
#
base                     /home/espen/miniconda3
clinica                  /home/espen/miniconda3/envs/clinica
homl3                 *  /home/espen/miniconda3/envs/homl3
pydata                   /home/espen/miniconda3/envs/pydata

$ cond env config vars list

$ echo $PATH
/home/espen/miniconda3/envs/homl3/bin:/home/espen/miniconda3/condabin:/home/espen/.cargo/bin:/home/espen/.zig:/home/espen/.config/emacs/bin:/home/espen/.local/scripts:/home/espen/.local/bin:/home/espen/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

$ uname -a
Linux forsker-pc 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct  9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

$ env
VNCDESKTOP=forsker-pc:2 (espen)
TEXINPUTS=.:/home/espen/.config/emacs/.local/straight/build-29.1/auctex/latex:
CONDA_PROMPT_MODIFIER=(homl3) 
MAIL=/var/mail/espen
LC_TIME=nb_NO.UTF-8
SSH_CLIENT=<redacted>
USER=espen
SSH_AGENT_PID=1055174
XDG_SESSION_TYPE=x11
SHLVL=2
CONDA_SHLVL=2
LESS=-R
MOTD_SHOWN=pam
OLDPWD=/home/espen
HOME=/home/espen
DESKTOP_SESSION=xfce
SSH_TTY=/dev/pts/1
LSCOLORS=Gxfxcxdxbxegedabagacad
ZSH=/home/espen/.oh-my-zsh
HUSHLOGIN=FALSE
PANEL_GDK_CORE_DEVICE_EVENTS=0
OPENAI_API_KEY=<redacted>
_ZSH_TMUX_FIXED_CONFIG=/home/espen/.oh-my-zsh/plugins/tmux/tmux.extra.conf
PAGER=less
LC_MONETARY=nb_NO.UTF-8
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
_CE_M=
LOGNAME=espen
_=/home/espen/.config/emacs/bin/doom
XDG_SESSION_CLASS=user
XDG_SESSION_ID=25
TERM=dumb
_CE_CONDA=
PATH=/home/espen/miniconda3/envs/homl3/bin:/home/espen/miniconda3/condabin:/home/espen/.cargo/bin:/home/espen/.zig:/home/espen/.config/emacs/bin:/home/espen/.local/scripts:/home/espen/.local/bin:/home/espen/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
SESSION_MANAGER=local/forsker-pc:@/tmp/.ICE-unix/1055157,unix/forsker-pc:/tmp/.ICE-unix/1055157
LC_ADDRESS=nb_NO.UTF-8
XDG_MENU_PREFIX=xfce-
XDG_RUNTIME_DIR=/run/user/1000
DISPLAY=:2.0
REMOTEHOST=<redacted>
LC_TELEPHONE=nb_NO.UTF-8
LANG=en_US.UTF-8
DESKTOP_STARTUP_ID=xfce4-panel/|usr|bin|emacs/1056424-9-forsker-pc_TIME80105680
XDG_CURRENT_DESKTOP=XFCE
ZSH_TMUX_TERM=screen-256color
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
XMODIFIERS=
CONDA_PYTHON_EXE=/home/espen/miniconda3/bin/python
SSH_AUTH_SOCK=/tmp/ssh-XXXXXXlByfKn/agent.1055173
LC_NAME=nb_NO.UTF-8
SHELL=/usr/bin/zsh
CONDA_DEFAULT_ENV=homl3
LC_MEASUREMENT=nb_NO.UTF-8
LC_IDENTIFICATION=nb_NO.UTF-8
PWD=/home/espen/PhD/adni
FZF_DEFAULT_COMMAND=rg --files --hidden --glob "!.git/*"
CONDA_EXE=/home/espen/miniconda3/bin/conda
VIRTUAL_ENV_DISABLE_PROMPT=1
ZSH_TMUX_CONFIG=/home/espen/.tmux.conf
SSH_CONNECTION=<redacted>
XDG_CONFIG_DIRS=/etc/xdg
XDG_DATA_DIRS=/usr/local/share:/usr/share
LC_NUMERIC=nb_NO.UTF-8
CONDA_PREFIX=/home/espen/miniconda3/envs/homl3
LC_PAPER=nb_NO.UTF-8
EDITOR=vim

(cond env config vars list returned just a blank line.)

This is after the first activation of the conda environment(conda-env-activate "homl3"). After the second activation no commands are available since PATH="".

EDIT add: The second activation can be the same or another environment. Killing the buffer after the first activation and then opening it again does not help, I have to restart emacs to be able to activate a second conda environment.

dizzyyogi commented 1 month ago

Dear @necaris,

First of all, a big thank you for your great package!

I am also able to reproduce the same issue, systematically. For me, it is with conda-env-autoactivate-mode set to t, upon generating a commit message with magit.

This causes a call to: (conda-env-activate-path "/") Then in function conda-env-activate-path, this causes (conda--get-activation-parameters "/") to return:

s(conda-env-params "" nil nil nil nil nil)

And (conda-env-params-path params)

to return the empty string "", which is then used to set PATH and exec-path.

Here is the stack trace when using debug-on-entry on function conda-env-activate-path:

Debugger entered--entering a function:

  • conda-env-activate-path("/") (let ((env-name (or name (conda--read-env-name))) (env-dir (conda-env-name-to-dir env-name))) (conda-env-activate-path env-dir)) conda-env-activate("/") (if (not (eql env-path nil)) (conda-env-activate env-path) (if conda-message-on-environment-switch (message "No Conda environment found for <%s>" (buffer-file-name)))) (let ((inferred-env (conda--infer-env-from-buffer)) (env-path (cond ((and (boundp 'conda-project-env-path) conda-project-env-path) conda-project-env-path) ((not (eql inferred-env nil)) (conda-env-name-to-dir inferred-env)) (t nil)))) (if (not (eql env-path nil)) (conda-env-activate env-path) (if conda-message-on-environment-switch (message "No Conda environment found for <%s>" (buffer-file-name))))) conda-env-activate-for-buffer() (condition-case err (conda-env-activate-for-buffer) ((debug error) (message "Error: %S" err) nil)) (progn (condition-case err (conda-env-activate-for-buffer) ((debug error) (message "Error: %S" err) nil))) (if filename (progn (condition-case err (conda-env-activate-for-buffer) ((debug error) (message "Error: %S" err) nil)))) (let ((filename (buffer-file-name))) (if filename (progn (condition-case err (conda-env-activate-for-buffer) ((debug error) (message "Error: %S" err) nil))))) conda--switch-buffer-auto-activate(#) apply(conda--switch-buffer-auto-activate #)

    f(advice conda--switch-buffer-auto-activate :after #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program! Use set-buffer' instead. That avoids\nmessing with thewindow-buffer' correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call pop-to-buffer' to select the buffer in\nanother window. In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\nswitch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using read-buffer'.\nThe variableconfirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name. If BUFFER-OR-NAME is\nnil, switch to the buffer returned byother-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling pop-to-buffer'. It has no effect when the option\nswitch-to-buffer-obey-display-actions' is non-nil.\n\nThe option switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nIf the optionswitch-to-buffer-obey-display-actions' is non-nil,\nrun the function pop-to-buffer-same-window' instead.\nThis may display the buffer in another window as specified by\ndisplay-buffer-overriding-action', display-buffer-alist' and\nother display related variables. If this results in displaying\nthe buffer in the selected window, window start and point are adjusted\nas prescribed by the optionswitch-to-buffer-preserve-window-point'.\nOtherwise, these are left alone.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0xcb2a45e9bf781b1>)) #<bytecode -0x1bd32d4d8e034264>))(#)

    apply(#f(advice conda--switch-buffer-auto-activate :after #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program! Use set-buffer' instead. That avoids\nmessing with thewindow-buffer' correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call pop-to-buffer' to select the buffer in\nanother window. In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\nswitch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using read-buffer'.\nThe variableconfirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name. If BUFFER-OR-NAME is\nnil, switch to the buffer returned byother-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling pop-to-buffer'. It has no effect when the option\nswitch-to-buffer-obey-display-actions' is non-nil.\n\nThe option switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nIf the optionswitch-to-buffer-obey-display-actions' is non-nil,\nrun the function pop-to-buffer-same-window' instead.\nThis may display the buffer in another window as specified by\ndisplay-buffer-overriding-action', display-buffer-alist' and\nother display related variables. If this results in displaying\nthe buffer in the selected window, window start and point are adjusted\nas prescribed by the optionswitch-to-buffer-preserve-window-point'.\nOtherwise, these are left alone.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0xcb2a45e9bf781b1>)) #<bytecode -0x1bd32d4d8e034264>)) #) switch-to-buffer(#)

    (# nil nil nil)

    server-switch-buffer--with-editor-server-window-alist(# # nil nil nil) apply(server-switch-buffer--with-editor-server-window-alist # (# nil nil nil)) server-switch-buffer(# nil nil nil) server-execute(#<process server <5>> (("/Users/dizzyyogi/config/.git/COMMIT_EDITMSG")) nil nil nil nil nil)

    f(compiled-function () #<bytecode -0x11ed6c7cdc9fab75>)()

    server-execute-continuation(#<process server <5>>) server-process-filter(#<process server <5>> "-dir /Users/dizzyyogi/config/ -current-frame -t...")

So, it seems in that situation, the conda env detected for the commit message buffer is "/", and systematically produces the command: (conda-env-activate-path "/") causing the issue described above.

You might have a look at how I personnally addressed the issue in branch fix_improvements_yd of my fork dizzyyogi/conda.el.

Kind regards