0

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:

/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin

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?

5
  • 1
    What's Your output of echo $PATH? Mar 5, 2015 at 13:40
  • 1
    How did you install dmd (and also note that it is not good to install into /usr/bin )
    – mmmmmm
    Mar 5, 2015 at 13:50
  • What does type -p dmd show? This is the dmd you are actually running
    – mmmmmm
    Mar 5, 2015 at 13:56
  • re the install we do need to know where it was installed from so we can see the documentation
    – mmmmmm
    Mar 5, 2015 at 13:56
  • Let us continue this discussion in chat.
    – mmmmmm
    Mar 5, 2015 at 13:57

3 Answers 3

0

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.

1
  • My 2nd § is inspired from @Mark 1st comment :).
    – dan
    Mar 5, 2015 at 14:36
0

If /usr/bin/dmd works and your path has /usr/bin in it, and your path is exported, then you can just type dmd. Otherwise you can change your path like this:

echo "export PATH=\"/usr/bin:$PATH\"" >> .profile

after which every new terminal will have the path you want. (this is the method used by homebrew, macports, etc)

1
  • make sure your PATH is exported for it to work. Mar 5, 2015 at 14:18
-1

if the only thing you need to call is dmd, how about putting an alias in your ~/.profile?

add this to .profile:

alias dmd='/usr/bin/dmd'

then open a new terminal, or type source ~/.profile to relaunch .profile.

You can also type the alias command directly in the terminal and test it out first. But it will not be around next time unless you put it in ~/.profile.

I do this quite a bit. Don't like to mess with the PATH for every single app that needs bash launches and it avoids stepping on something else by mistake.

Then you just type:

dmd ...your arguments...

essentially, alias here does exactly what you don't want to do, it types out /usr/bin/dmd.

You must log in to answer this question.