Zend certified PHP/Magento developer

Using ZSH under WSL2 / Ubuntu 20.04, shell script not working correctly (direnv issues)

I followed this guide to set up WSL2 with ZSH/ oh-my-zsh. When I open a new Ubuntu terminal I do get ZSH to load, but my rbenv and direnv don’t quite work right (and yes, they’re set up properly in the .zshrc, please read past the code block):

/home/will/.zshrc:122: command not found: rbenv
/home/will/.zshrc:126: command not found: direnv
➜  will

If I use direnv at this point, the executable runs but direnv allow does not function (no output).

However, if I immediately re-run the shell script via exec $SHELL then these errors do not occur, and direnv allow works great.

Is there some timing issue where the environment is still spinning up or something and that’s why everything operates properly after the second execution of the shell script? How can I make this work correctly the first time?

A note, I have this problem in both Windows Terminal and if I load ubuntu direct from powershell, it doesn’t seem to be terminal-related.

Thanks!