Inconsistent Environment on Linux
See original GitHub issueDescribe the bug
The runner’s environment is populated with the contents of the .env
file but ignores the operating system’s standard /etc/environment
file. This leads to the situation that commands – depending on how they are invoked – see a different environment. This is most apparent with sudo
.
To Reproduce Steps to reproduce the behavior:
echo 'ENV_TEST=true' >>/etc/environment
while building the runner- Run
env; sudo env
within an action executed with the runner that has the/etc/environment
line - Notice that
ENV_TEST
is only available insudo
’senv
🔥 It is possible that this is an issue with https://github.com/actions-runner-controller/actions-runner-controller and not this project, I am here to find this out. 😉
Expected behavior
I would expect that every command’s environment is prepopulated with the values from /etc/environment
since that is the operating system’s standard. I guess it could also make sense to argue in another direction, but then no program should ever see the values from /etc/environment
; this is definitely going to be significantly harder to achieve than sourcing /etc/environment
before .env
in LoadAndSetEnv
so that .env
overwrites anything in /etc/environment
.
Note that the separation between /etc/environment
and .env
would also allow setting environment variables for all users and the runner user separately.
Runner Version and Platform
All Linux versions are affected, and I am specifically coming from https://github.com/actions-runner-controller/actions-runner-controller/issues/1135.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top GitHub Comments
I test my idea from above and it works as expected. I am not yet entirely sure if it should be
exec env --
orexec env -i --
but that is something for ARC. Thanks again everyone, and I might come back to your offer @ethomson. 😉Hi @Fleshgrinder, Thanks for filing this issue! We are investigating the bug you described, so we will get back to you as soon as we have more informations.