title: Setting zsh PATH not producing desired order
body: <p>I'm using Homebrew on Mac OS X 10.8.3. Homebrew wants the <code>/usr/local/bin</code> directory earlier in the PATH than <code>/usr/bin</code>, otherwise system-provided programs will be used instead of Homebrew managed replacements.</p>
  
  <p>I'm using zsh, and in my <code>.zshenv</code> I reset the PATH, and then use path_helper to initialize it, like so:</p>
  
  <pre><code>if [ -x /usr/libexec/path_helper ]; then
    PATH=''
    eval `/usr/libexec/path_helper -s`
  fi
  </code></pre>
  
  <p>Immediately following this, also in <code>.zshenv</code>, I prepend <code>/usr/local/bin</code> to the PATH.</p>
  
  <pre><code>export PATH="/usr/local/bin:$PATH"
  </code></pre>
  
  <p>There are various other additions to $PATH. RVM, <code>/usr/local/sbin</code> and my personal <code>bin</code> directory:</p>
  
  <pre><code>export PATH=$HOME/.rvm/bin :$PATH
  ...
  export PATH=$PATH:/usr/local/sbin:$HOME/bin
  </code></pre>
  
  <p>Finally, I use <code>typeset -u</code> to remove any duplicates (although where they are coming from is a mystery to me) from the PATH.</p>
  
  <pre><code>typeset -U PATH 
  </code></pre>
  
  <p>After all of this here is what my PATH looks like:</p>
  
  <pre><code>/Users/mark/.rvm/gems/ruby-1.9.3-p374/bin
  /Users/mark/.rvm/gems/ruby-1.9.3-p374@global/bin
  /Users/mark/.rvm/rubies/ruby-1.9.3-p374/bin
  /Users/mark/.rvm/bin
  /usr/bin
  /bin
  /usr/sbin
  /sbin
  /usr/local/bin
  /usr/local/sbin
  /Users/mark/bin
  </code></pre>
  
  <p>I know that <code>/etc/paths</code> sets these paths:</p>
  
  <pre><code>/usr/bin
  /bin
  /usr/sbin
  /sbin
  /usr/local/bin
  </code></pre>
  
  <p>so I edited that file and removed the <code>/usr/local/bin' option so that the only place it is being set is in</code>.zshenv`.</p>
  
  <p>All of this is contained in my dotfile repository on GitHub (<a href="https://github.com/zan5hin/dotfiles" rel="noreferrer">https://github.com/zan5hin/dotfiles</a>), and is being used on two laptops. On the first laptop the path is correct, with <code>/usr/local/bin</code> immediately following the RVM entries. On the second laptop it appears as I detailed above. </p>
  
  <p>I am at a loss to explain why the path is incorrect on the second machine when the zsh configuration is an identical copy.</p>
  
  <p>Can anyone suggest why the path would be out of order?</p>
  
  <p>Thanks.</p>