Weird PATH order issue with neovim terminal and Conda environment

Hi,
this is such a weird and niche issue that I don’t even know where to begin debug it.

Everything works fine in this case:

  1. Start terminal. echo $PATH:/usr/local/bin:/usr/local/sbin: ....
  2. Start nvim.
  3. Start nvim’s terminal and conda activate myenv
  4. echo $PATH~/miniconda3/envs/myenv/bin:/usr/local/bin:/usr/local/sbin:...

However if I happen to activate conda environment before entering nvim, the order of my path variable is messed up.

  1. Start terminal. echo $PATH:/usr/local/bin:/usr/local/sbin: ....
  2. conda activate myenv, then echo $PATH~/miniconda3/envs/myenv/bin:/usr/local/bin:/usr/local/sbin: ....
  3. Start nvim
  4. Conda environment is detected as active, however
    echo $PATH/usr/local/bin:/usr/local/sbin:~/miniconda3/envs/myenv/bin...
    Conda environment is now behind /usr/local/bin, which means system’s python, pip, ipython, … in local bin are used instead of the one in my conda environment.
  5. conda activate myenv again still doesn’t solve the problem. echo $PATH/usr/local/bin:/usr/local/sbin:~/miniconda3/envs/myenv/bin...
  6. I have to conda deactivate then conda activate myenv to put the conda env path in front again.

Does anyone know why and have a fix for this?

Is your path also changed when running /usr/bin/nvim instead of just
nvim? Does the path still change if you use nvim -u NONE instead of
just nvim?

Thanks.
I install neovim head with brew and only has /usr/local/bin/nvim, but no /usr/bin/nvim`.

And the problem still persists with nvim -u NONE or nvim --clean, the order in the $PATH is changed.

Is /usr/local/bin/nvim the neovim binary or a script that executes the
neovim binary? On linux you can use file /usr/local/bin/nvim to find
out - not sure how you’d do that on OSX.

It’s an executable /usr/local/bin/nvim: Mach-O 64-bit executable x86_64