0

Please note: This is not a question related to pip or python.

I am trying to make sense of why I see a "permission error" instead of "path not found" error.

I have done many installations and uninstallation for different softwares including python. So I can't recall how the setup was many years back.

My core question is why I see an "zsh: permission denied: pip" instead of "pip not found". When an executable doesn't exist, I would expect it to be say "not found" vs pointing to a possible permission issue.

And secondly; is there a way in linux\unix\mac to identify all commands\symlinks\aliases that are broken now?

Here is my terminal output

ayusman :$ pip
zsh: permission denied: pip
ayusman :$ which pip
pip not found
ayusman :$ type pip
pip not found
ayusman :$

Thank you.

4
  • That might be consistent with a permissions error on one of the elements in your PATH definition. zsh tells you why it could not descend the directory tree, the others just tell you it didn't. Commented Aug 5, 2025 at 7:49
  • Both which and type are looking for an executable. Since pip cannot be executed, the returned message is expected. For your second question, you will need to define broken, e.g., is an executable in /usr/bin that can be run only by members of a certain group broken? Finding a dangling symlink can be done, determining if an alias is broken (again, define broken) would require executing each alias the shell knows about. Commented Aug 5, 2025 at 16:30
  • @doneal24 by broken I mean when an executable or symlink doesn't exist is there a way to scan my laptop and find out which will cause a not found or permission issue? Commented Aug 5, 2025 at 20:17
  • In order to check on which files don't exist, you will need to provide a list of files that should exist and check on everything on that list. So, short answer is no, no such process is available. Commented Aug 6, 2025 at 12:26

1 Answer 1

2

What you are seeing is consistent with the existence of file named pip that is somewhere on the PATH, but that does not have execute permission.

This reproduces the symptoms with an executable named tst:

#!/usr/bin/env zsh

PATH=/bin:/usr/local/bin:~/bin
rm ~/bin/tst
ls -fo ${^path}/tst
#=> ls: /bin/tst: No such file or directory
#=> ls: /usr/local/bin/tst: No such file or directory
#=> ls: /Users/me/bin/tst: No such file or directory

print '================'
ls -o ~/bin/tst; which tst; tst
#=> ls: /Users/me/bin/tst: No such file or directory
#=> tst not found
#=> ./p2:11: command not found: tst

print '================'
print 'echo "Executing program: $0"' > ~/bin/tst
ls -o ~/bin/tst; which tst; tst
#=> -rw-r--r--  1 me  33 Aug  6 12:24 /Users/me/bin/tst
#=> tst not found
#=> ./p2:18: permission denied: tst

print '================'
chmod +x ~/bin/tst
ls -o ~/bin/tst; which tst; tst
#=> -rwxr-xr-x  1 me  33 Aug  6 12:24 /Users/me/bin/tst
#=> /Users/me/bin/tst
#=> Executing program: /Users/me/bin/tst

As the last section demonstrates, one way to change this is to set the execute permissions on the file. However, the lack of permissions may indicate that there are other problems with the installation, including possible security issues. It's probably best to re-install the program, maybe via homebrew or another package manager.

1
  • pip could be a non-executable file in $path, but it could also be a directory in $path (which can't be executed whether or not it has execution permissions; which really translate to search permissions for directories). Like after mkdir ~/bin/pip in your example. It would be a good idea to add a -d option in your ls commands so it would be more helpful if the OP was in this situation. -o also potentially hides part of the information pertinent to execute permission. Commented Sep 14, 2025 at 20:02

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.