I finally got the reason it prevented environment variables from being expanded is that I switched to zsh shell, and it doesn't load those environment variables defined in ~/.zshrc
when MacVim is launched. When I used bash shell, I defined all of those variables in ~/.bash_profile
.
The solution is to define those variables in ~/.zshenv
, not ~/.zshrc.
I suspect that the MacVim is assumed to be launched as a shell script, and when a command is executed as a shell script in zsh, only ~/.zshenv
is loaded.