I want to run a program ds9 from the Terminal. The program is clearly in the PATH, which I determined by running:

which ds9

But when I run the command by typingds9, it shows me the following error:

-bash: /Applications/ds9.app/Contents/MacOS/ds9: No such file or directory

I can still execute it fine if I use the full path as follows:


What's going on? Why is it trying to run /Applications/ds9.app?

Permissions are as follows:

-rwxrwxr-x@ 1 evgenii  staff  18613852  9 Nov 20:13 /Users/evgenii/miniconda3/envs/iraf/bin/ds9


Here is the output of running type -a ds9 command:

type -a ds9
ds9 is aliased to `/Applications/ds9.app/Contents/MacOS/ds9 -xpa no'
ds9 is /Users/evgenii/miniconda3/envs/iraf/bin/ds9
  • 4
    Don't use which. It's an external program, so it can't tell about shell aliases. – Barmar Jan 9 at 23:23
  • Receipe to work with commands: use PATH rather than alias and type rather than which. – dan Jan 10 at 9:10

The command is apparently aliased to a broken alias. First, check for all the matches for ds9 in PATH environment variable, by executing the following command:

type -a ds9

As per your updated question, it's apparent from the output of type -a ds9 command, that an alias is shadowing the actual command.

To execute the actual command by ignoring the alias, and without specifying the full path, prepend a \ (backslash) character before the command. This ignores any bash defined alias.

If you do not wish to prepend the backslash before the command every time, figure out where the alias is being created, and either remove it, or override the alias with the actual command.

  • 1
    The ds9 alias definition is most probably in ~/.bashrc and should be removed there (because it’s a bad method leading to this kind of problem). grep ds9 ~/.bashrc will confirm it. – dan Jan 10 at 9:02

I see this was solved for the asker, but for future readers I want to mention that it could also be the case that the command was hashed and then the file removed. (See help hash for info.)

type -a commandname will not show you that, only type commandname will.

In this case, hash -d ds9 would be all that would be needed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .