I have a following lines in my .bash_profile.

if [ -d "$HOME/bin" ] ; then

I think I found it somewhere in the internet.

Is it also ok, if I write only PATH="$HOME/bin:$PATH" without checking directory existence? Does it cause a problem if I add a non-existing path to $PATH?

  • As @Anthon already answered there is not problem with adding non-existing paths, but bash will always complain if it doesn't find a given command, as usual. I don't see the point of the above test. – user13742 Oct 18 '13 at 7:43

It is easy to try this out. bash will not complain if you add a non-existing directory in PATH (but obviously it will not find any commands or scripts in there either).

If you later create the directory and store executables in there, bash will find them.


Think about it another way, the only reason to check any following path in PATH is because there was an error finding a file at the previous one. So errors will cause no problem, in fact they are expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.