Can't run one particular program from Terminal without using its full path
I want to run a program ds9
from the Terminal. The program is clearly in the PATH, which I determined by running:
which ds9
/Users/evgenii/miniconda3/envs/iraf/bin/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:
/Users/evgenii/miniconda3/envs/iraf/bin/ds9
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
Update:
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
Solution 1:
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.
Solution 2:
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.