Open zfields opened 2 years ago
I figured it out. You are passing the parameter -e HOME
to the docker run
command. In doing so, you are setting the HOME
environment variable to /github/home/
, instead of leaving it as /root
which is the root
user's home directory.
This causes me a problem, because I install tools in my container and the tools subsequently create subfolders under the user's home directory. When the runner changes the meaning of $HOME
, then my installed tools can no longer identify where their directories are installed.
As a workaround, I am using bash
as the entrypoint and using an inline environment variable declaration to restore HOME
to the expected value. This is undesirable, because I can no longer use the ENTRYPOINT
keyword in the docker file or the action YAML for the utility I wish to run.
Workaround:
bash -c "HOME=/root arduino-cli compile --build-property build.extra_flags=-Werror --fqbn arduino:avr:uno --warnings all sketch.ino"
If updating the HOME
environment variable is not critical to the functionality of GitHub CI, please consider removing it from the docker run
command. :pray:
+1 for not overwriting the $HOME folder as container behavior may rely on it. Would be better if Github had their own $GITHUB_HOME.
I did some digging, and HOME
makes the list of RESERVED variables in some texts...
https://www.linuxtopia.org/online_books/introduction_to_linux/linux_Reserved_variables.html
While in others, it is heavily frowned upon... https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
It is unwise to conflict with certain variables that are frequently exported by widely used command interpreters and applications:
If nothing else, this should be a heavy indicator of potential name collision and impact to containerized applications.
environment variables are pretty much equivalent to global variables and modification should be avoided for that reason. they should also not be relied upon to have a specific or known-good value, because as you've discovered, they can be modified or relied upon by anything. call your executables via their absolute path, and use absolute paths everywhere you use relative paths or rely on the $PATH environment variable today.
@jj51726-jd nothing you said is wrong, but I'm afraid it misses the mark in this case. That being said, it does indicate that I was unclear in my writing above, and this is an opportunity to clarify the original text.
I'll restate it here, in case it helps to clarify the problem for others...
During image creation, I install certain tools through my Dockerfile
. Then, during a subsequent step of the image creation, I instruct one of the newly installed tools to install it's own dependencies. The tool uses ${HOME}
to identify where it should install tools - without prompting or taking input from me.
After container instantiation, the tool then looks back to ${HOME}
to find it's dependencies. However, the GitHub Action Runner has overridden ${HOME}
, and now the tool thinks it's dependencies are not installed.
In this instance, I have no option to supply paths of any kind, everything is internal to the 3rd-party tool. Furthermore, this is a fairly common pattern, so we can't just blame this one tool provider and expect them to change it and fix everything. It would be easier, for the GitHub Action Runner to create it's own HOME
variable (like GITHUB_HOME
as @sidwarkd suggested), because the runner would be aware of it and could use it as necessary.
As a result, my workaround was to provide the original value of ${HOME}
to the tool, so it would be able to locate the dependencies it installed during image creation.
This is an awful bug in Github actions. Who thought its OK to overwrite $HOME variable? Overwriting $HOME variable breaks a lot of intuitive assumptions about Linux environment. What is the reason for overwriting $HOME variable? If overwriting $HOME variable does not benefit the users directly, this needs to be fixed ASAP.
Describe the bug On my development machine, when I invoke a container (as
root
), with a givenentrypoint
andargs
, I am seeing a different behavior than when the runner invokes the container with identicalentrypoint
andargs
in the cloud with GitHub CI.The runner invokes the container with the following parameters:
Removing the environment variables we are left with:
Removing the volumes (except for the source code) we are left with:
Finally remove the
name
andlabel
parameters and we are left with:On my machine, I invoke the container similarly, like so:
However, when I invoke the container locally, I get this result
while the result I receive in GHCI is:
It is behaving as if the file system is messed up. The image installs the supporting files for the Arduino CLI in
/root
, and the volumes mounted by GHCI are limited to/var
and/github
so they should not be interfering with each other.What else is happening that would make this behave differently?
To Reproduce Steps to reproduce the behavior:
Compile the following Dockerfile into an image
Attempt to compile an Arduino
.ino
fileSee error
Expected behavior Given the same inputs, I would expect the Docker container to produce the same outputs both locally and in the cloud with GHCI.
Runner Version and Platform
Version of your runner?
OS of the machine running the runner?
ubuntu-latest
What's not working?
Please include error messages and screenshots.
Job Log Output
If applicable, include the relevant part of the job / step log output here. All sensitive information should already be masked out, but please double-check before pasting here.
Runner and Worker's Diagnostic Logs
If applicable, add relevant diagnostic log information. Logs are located in the runner's
_diag
folder. The runner logs are prefixed withRunner_
and the worker logs are prefixed withWorker_
. Each job run correlates to a worker log. All sensitive information should already be masked out, but please double-check before pasting here.