Macos – Executing command via ssh not sourcing ~/.bashrc in Bash 4

bashmacosssh

According to the bash invocation sequence, if a non-interactive, non-login bash shell is invoked via ssh, it's supposed to source ~/.bashrc. This works just fine with the OS X-shipped Bash 3.2.48(1)-release.

However, when I install bash 4.2.8(2)-release and set that as my login shell, executing a command via ssh (e.g. ssh <host> <command>) doesn't source my ~/.bashrc.

Does anybody know what's wrong, or how I can work around this?

Best Answer

Probably way late, but I've run into this issue, and my solution was adding

if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi

to my ~/.bash_profile.