Wanted to perhaps introduce you to using nix along with direnv and flakes to make your dependencies declarative rather than determined by factors beyond your control.
In my bash scripts, I often create a .envrc file that points to my flake and sits alongside the bash file. Then, when I navigate into the directory of the script/project, I can make direnv and nix automatically load all dependencies (which virtually guarantees them eliminating the need to check for them).