Fix ZSH environment in non-login non-interactive shells
What does this MR do?
If the shell is non-login non-interactive, like when the runner sends a command with SSH, it will not load .zshrc, .zprofile, /etc/zshrc and /etc/zprofile. Only .zshenv.
This makes sure that we properly setup our $PATH
and load our .zshrc
when executing commands.
Also it sets LANG
and LC_ALL
to fix Warning: the environment variable LANG is not set!
in https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/macstadium/orka/-/jobs/1094034917#L57
Why was this MR needed?
What's the best way to test this MR?
Before:
ssh -o Port=8826 gitlab@10.221.188.127
Loading .zshenv
Loading /etc/zprofile
Loading .zprofile
Loading /etc/zshrc
Loading .zshrc
gitlab@Gitlabs-iPro ~ % printenv
...
PATH=/Users/gitlab/.asdf/shims:/Users/gitlab/.asdf/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
...
ssh -o Port=8826 gitlab@10.221.188.127 printenv
Loading .zshenv
...
PATH=/usr/bin:/bin:/usr/sbin:/sbin
...
After:
ssh -o Port=8826 gitlab@10.221.188.127
Loading .zshenv
Loading /etc/zprofile
Loading .zprofile
Loading /etc/zshrc
Loading .zshrc
gitlab@Gitlabs-iPro ~ % printenv
...
PATH=/Users/gitlab/.asdf/shims:/Users/gitlab/.asdf/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
...
ssh -o Port=8826 gitlab@10.221.188.127 printenv
Loading .zshenv
Loading .zshrc
...
PATH=/Users/gitlab/.asdf/shims:/Users/gitlab/.asdf/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
...
What are the relevant issue numbers?
Closes #70 (closed)
Edited by Adrien Kohlbecker