To answer your question, your PATH has to be modified to:
PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/opt/X11/bin:/usr/texbin
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.
Your PATH variable got contaminated by some irregular file content: either your git file in /etc/paths.d/, /etc/profile or ~/.MacOSX/environment.plist or all three are corrupted.
Use shiftcmdG in Finder to jump to each of the folders and check the content of them.
/etc/paths.d/ should contain a file git with the content /usr/local/git/bin
. If you have installed other apps like X11 there may be additional files in paths.d - all containing paths.
The file profile in /etc/ should contain at least
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
The file environment.plist should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin</string>
</dict>
</plist>
The PATH string may contain other paths as well. The file may contain other keys - depending on other installs you have made previously.
If you have found irregular content in one of the files simply replace it with the content shown above. You have to be an admin to modify the first two files because they are root:wheel realm. If you use TextEdit or another text editor to modify them, be sure to save them as plain text and without file extension (i.e. .txt). You can ignore a missing ~/.MacOSX/environment.plist because it isn't supported in your environment (system version) anymore, besides you use some hacks.
Best Answer
This installs or updates Command Line Tools. It can be done manually too, by downloading the tools from Developer Website.
How to compile with Command Line Tools for Xcode after deleting the Xcode.app application bundle?
Can't update Developer Tools on Mojave
You might need to point it to the install location of the tools too.
Then restart the Terminal/ VSCode.