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?

  • 1
    What's Your output of echo $PATH? – Mateusz Szlosek Mar 5 '15 at 13:40
  • 1
    How did you install dmd (and also note that it is not good to install into /usr/bin ) – Mark Mar 5 '15 at 13:50
  • @MateuszSzlosek Edited my question. – nbro Mar 5 '15 at 13:54
  • @Mark I think it was the default directory, or it was installed by another program or update.. I don't remember having explicitly set the installation path.. – nbro Mar 5 '15 at 13:55
  • What does type -p dmd show? This is the dmd you are actually running – Mark Mar 5 '15 at 13:56
1

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.

  • My 2nd § is inspired from @Mark 1st comment :). – daniel Azuelos Mar 5 '15 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)

  • I know it would work, but it seems that it is first searching on another path, but it is not finding it... – nbro Mar 5 '15 at 14:12
  • make sure your PATH is exported for it to work. – user1133275 Mar 5 '15 at 14:18
0

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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