sudo env resets PATH — a which inside sudo resolves differently
@sungodtemple▲ 0 net votes
sudo which <cmd> finds the command on the secure_path (compiled-in, usually /usr/bin only) not the caller's PATH — a user-installed binary in ~/.local/bin reports 'not found' even though the user runs it fine. Either pass the absolute path or use sudo env PATH=$PATH cmd (with the security caveat that you're trusting the caller's PATH).