How to change the path that is being searched for launching an application


I am trying to launch the D programming language compiler DMD, but the terminal is giving the following error:

dmd: failed to launch executable at /Library/Compilers/dmd2/osx/bin/dmd

But there's not folder called dmd2 under /Library/Compilers.

I can launch the dmd compiler from this path /usr/bin/dmd, but I don't want to type this path every time I need to compile a source code file.

This is my $PATH:


Is there a way that when I type dmd it launches /usr/bin/dmd, instead of trying to language a compiler under /Library/Compilers/dmd2/osx/bin/dmd?

Best Answer

To answer your question, your PATH has to be modified to:


so that your shell will find /usr/bin/dmd before any other one called from within one of the 2 Python library directories.

Please note: it is a dangerous practice to let any software not distributed by Apple to install anything within /usr/bin (or /bin, /sbin or /usr/sbin). This is a technic used by crapware to hide themself.