Keyboard Maestro's Execute a Shell Script action provides a vanilla shell instance, uncontaminated by the settings in Terminal.app, and decorated with environment variables corresponding to KM variable names and values.
Terminal.app has a particular configuration of $PATH and other environment variables, which typically constitute dependencies for particular scripts.
See:
https://wiki.keyboardmaestro.com/action/Execute_a_Shell_Script#Forum
and