title: NSTask not picking up $PATH from the user's environment
body: <p>I don't know why this method returns a blank string:</p>
  
  <pre><code>- (NSString *)installedGitLocation {
      NSString *launchPath = @"/usr/bin/which";
  
      // Set up the task
      NSTask *task = [[NSTask alloc] init];
      [task setLaunchPath:launchPath];
      NSArray *args = [NSArray arrayWithObject:@"git"];
      [task setArguments:args];
  
      // Set the output pipe.
      NSPipe *outPipe = [[NSPipe alloc] init];
      [task setStandardOutput:outPipe];
  
      [task launch];
  
      NSData *data = [[outPipe fileHandleForReading] readDataToEndOfFile];
      NSString *path = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
  
      return path;
  }
  </code></pre>
  
  <p>If instead of passing <code>@"git"</code> as the argument, I pass <code>@"which"</code> I get <code>/usr/bin/which</code> returned as expected. So at least the principle works.</p>
  
  <p>from the terminal</p>
  
  <pre><code>$ which which
  $ /usr/bin/which
  $
  $ which git
  $ /usr/local/git/bin/git
  </code></pre>
  
  <p>So it works there.</p>
  
  <p>The only thing I can think of is that <code>which</code> isn't searching through all the paths in my environment.</p>
  
  <p>This is driving me crazy! Does anyone have any ideas?</p>
  
  <p><strong>EDIT:</strong>  It looks like this is about setting up either NSTask or the user's shell (e.g., ~/.bashrc) so that the correct environment ($PATH) is seen by NSTask.</p>