title: PATH="/custom/dir:$PATH" prepending instead of appending - Conda vs Pyenv
body: <p>I have a Mac (latest software update) with Pyenv and Anaconda. I manage packages with Homebrew and have installed Python 3 with it. When I <code>echo $PATH</code> I get the following:</p>
  <pre><code>/Library/Frameworks/Python.framework/Versions/3.8/bin:
  \ /usr/local/bin:
  \ /usr/bin:
  \ /bin:
  \ /usr/local/sbin:
  \ /usr/sbin:
  \ /sbin:
  \ /Library/TeX/texbin:
  \ /Users/luca/.pyenv/versions/anaconda3-2020.02/condabin:
  \ /Users/luca/.pyenv/versions/3.8.5/bin:
  \ /Users/luca/.pyenv/bin
  </code></pre>
  <ol>
  <li><p>I do not know what sets up <code>/Library/Frameworks/Python.framework/Versions/3.8/bin</code>: this directory is non-existent on my Mac. I had previously installed Python without Homebrew that is <a href="https://github.com/Homebrew/legacy-homebrew/issues/27146" rel="nofollow noreferrer">why the directory was created</a>. I did remove that, but there is still something that exports that line in <code>$PATH</code>, but I cannot find it! Does someone have a guess? I did try and <code>grep -r /*</code> it, but that is too much of a search for my laptop to finish.</p>
  </li>
  <li><p>I set up in my <code>.zshenv</code> the code for initialising <code>pyenv</code> and <code>conda</code>. Of course, I did write <code>PATH=&quot;/dir/to/conda/bin:$PATH&quot;</code> and the same for <code>pyenv</code> (see code below). I do not understand why, but they end up at the <em>end</em> of <code>$PATH</code>. Does someone know why? Is it because of <code>eval &quot;$(pyenv init -)&quot;</code> being evaluated before <code>conda</code>?</p>
  </li>
  </ol>
  <pre><code># &gt;&gt;&gt; pyenv initialize
  export PYENV_SHELL=$SHELL
  export PATH=&quot;/Users/luca/.pyenv/bin:$PATH&quot;
  export PATH=&quot;/Users/luca/.pyenv/versions/3.8.5/bin:$PATH&quot; #export Python 3.8 bin directory
  if command -v pyenv 1&gt;/dev/null 2&gt;&amp;1; then
      eval &quot;$(pyenv init -)&quot;
  fi
  # &lt;&lt;&lt; pyenv initialize &lt;&lt;&lt;
  
  # &gt;&gt;&gt; conda initialize &gt;&gt;&gt;
  # !! Contents within this block are managed by 'conda init' !!
  __conda_setup=&quot;$('/Users/luca/.pyenv/versions/anaconda3-2020.02/bin/conda' 'shell.zsh' 'hook' 2&gt; /dev/null)&quot;
  if [ $? -eq 0 ]; then
      eval &quot;$__conda_setup&quot;
  else
      if [ -f &quot;/Users/luca/.pyenv/versions/anaconda3-2020.02/etc/profile.d/conda.sh&quot; ]; then
          . &quot;/Users/luca/.pyenv/versions/anaconda3-2020.02/etc/profile.d/conda.sh&quot;
      else
          export PATH=&quot;/Users/luca/.pyenv/versions/anaconda3-2020.02/bin:$PATH&quot;
      fi
  fi
  unset __conda_setup
  # &lt;&lt;&lt; conda initialize &lt;&lt;&lt;
  </code></pre>