I am running MacOSX Sierra and have homebrew installed. So I'm trying to create compress-slide.sh script under ~/bin. In order for me to get rid of doing symlinks I added the ~/bin in my path so my path looks like this now: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/bin

I've set the path under /etc/paths and here is how it looks like:


But when I try which compress-slide.sh nothing is found, it doesn't give me the path I'm expecting which is ~/bin/compress-slide.sh I just wish to use this script when I'm on different directories. Also I made sure that I'm the owner of the script and that it has executable permission.

-rwxr-xr-x  1 dummyuser  dummyuser   135B Dec 28 18:13 compress-slide.sh

Here's the content of my script, just a simple command to test it works;

#!/usr/bin/env bash

echo 'test'

Here is my homebrew config:

ORIGIN: https://github.com/Homebrew/brew
HEAD: 9cd5a21b473f0271b162bbe7f77f7d1468c0cfa1
Last commit: 2 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 797542c1bf61c4cfc58c7a52a2534d154cc584d1
Core tap last commit: 8 days ago
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: octa-core 64-bit ivybridge
Homebrew Ruby: 2.0.0-p648
Clang: 8.0 build 800
Git: 2.10.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
Java: 1.8.0_60, 1.7.0_79
macOS: 10.12.2-x86_64
Xcode: 8.2.1
X11: N/A

Is this because of Homebrew conflicting with my setup? Has anyone encountered this as well?

  • 1
    No, it's because you have a ~ in your PATH. Please use /Users/YOURUSERNAME/bin instead. – nohillside Dec 28 '16 at 15:31
  • @patrix Thank you very much! I just spelled it out and it works! – JohnnyQ Dec 29 '16 at 1:16
  • Please don't add the answer to the question. – nohillside Dec 29 '16 at 13:28

Your issue has nothing to do with being lazy. The path_helper application prevents tilde and variable expansion. Here's a modified /private/etc/paths file.


The path_helperapplication constructs a string to be evaluated in /private/etc/profile using the current PATH variable along with those directories listed /private/etc/paths and files within /private/etc/paths.d.

/usr/libexec/path_helper -s
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/bin:\$HOME/local/bin"; export PATH;

The double quotes around the PATH variable prevent tilde expansion and the backslash before the dollar sign prevent variable expansion of $HOME.

  • Awesome I think this answers the question directly. Thanks! – JohnnyQ Dec 30 '16 at 9:44
  • Well done and excellent answer cutting to the direct cause of the path pain. +lots of votes I hope. – bmike Dec 30 '16 at 20:40

I would sym link the scripts you place out of the path to /usr/local/bin so you don't need to reason with ~ expansion in .dot files for your shell.

It's possible to have a durable way to ensure your enviroment is set up to handle ~ - but I'm a fan of having absolute paths there to avoid problems when you su to other users and have environment cross contamination as well as issues like you face.

This isn't anything about homebrew - purely about bash or whatever shell you are using.

  • also - apologies for basically saying "do the thing you said at the top you didn't want to do" by adding sym links - but they're really useful for the case you mention above. My suspicion is Patrix or another will get you a proper answer rather than my advice to punt on this one. : - ) – bmike Dec 28 '16 at 15:40
  • Thank you very much! I think should be stop being lazy and spell out the path if I can. – JohnnyQ Dec 29 '16 at 1:43
  • Just a follow up question, how would you sym link an entire folder for example the /Users/username/bin to /usr/local/bin as you were proposing? I know I can do ln -s /Users/username/bin/* /usr/local/bin but the problem with this approach is I'd have to do it every single time whenever I have new script? – JohnnyQ Dec 29 '16 at 2:27
  • No way to do that, you'd have to make a script to iterate over the folder and link / clean up as needed. In that case, fixing the path is probably worth the pain for that case. – bmike Dec 29 '16 at 2:45
  • hmm if that's the case then I'd probably stick with including my home bin in the path. I can deal with .dot files in it assuming they are just bunch of .DS_Store ones. Thank you again for your help. – JohnnyQ Dec 29 '16 at 7:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .