I am having this problem:
jorge@debian:~$ emacs
emacs: could not resolve realpath of "emacs": No such file or directory

My tests run without issue
jorge@debian:~$ echo $PATH
/home/jorge/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

jorge@debian:~$ /usr/local/bin/emacs --version       
GNU Emacs 28.0.50
Copyright (C) 2021 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

Emacs has been compiled from source and installed the last version in emacs-mirror https://github.com/emacs-mirror/emacs using --feature-comp and --with-x-toolkit=lucid as configure flags.

Thanks.