-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when changing JDK to something other than the default #28
Comments
Due to https://github.com/madhead/tyzenhaus/blob/master/.github/workflows/master.yml#L18-L26. Use this action first |
That's actually very interesting. This action is a Docker action and should be completely independent of the environment. I'll take a look, though. |
I looked into it more and it appears every user-set env variable in the runner is passed to Docker when it starts, so if JAVA_HOME is set at all it causes the failure. I even tried saving the original JAVA_HOME value so I could set it back, but that caused the same problem. Ex Docker output that breaks from the Github debug: Ex Docker output that succeeds: I was eventually able to get this working as long as I ran this action first, then the setup java action as @SettingDust mentioned. Still seems odd though, but not sure if the variables passed to the container are in your control, I couldn't find anything about how to control that. |
That was my first guess, that variables set in the workflow / worker leak into the container. Of course, the container has another JAVA_HOME (Java is installed into another directory). And the shell script (generated by Gradle Application Plugin) reads that property when it tries to execute the code of this action. Thus, it fails. However, this behavior seems super contr-intuitive to me and is shouldn't work that way! Probably it should be reported to GitHub Actions team or what. If the assumptions above are true, then there is not many things actions authors could do. |
Ok, environment definitely leaks into Docker actions :( I've made a minimal reproducible example here. Take a look at the actions execution log: https://github.com/madhead/actions-env-leak/runs/4575382091?check_suite_focus=true#step:5:54 Notice that after How do you think, @nateha1984, @SettingDust, maybe this one should be reported to the Actions team? |
I can't imagine how can they "fix" this. It's not a bug. For the users want to modify the env of container. So, I think we need to ask someone for the best practice. Notice in README is enough. |
Well, actually I didn't expect that. This "problem" is not specific to my action. It's just a matter of bad luck. I expect Docker container actions to be fully isolated of the workflow. With the variables leaking inside, you could potentially break any action that relies on environment variables. At least, I'd expect this be explicit: if one wants to overwrite the variable, she should be explicit. It seems like Docker container actions just inherit the whole environment… |
Add a few notes about `JAVA_HOME` leakage
I've added a few words in README about this issue. I've also created a topic on GitHub Community forum, but it was closed by a dang moderator bot as a spam :( |
This is what a support told me on my request to clarify the behavior:
|
So, I won't be able to do anything here... |
rewrote this action in typescript like any other normal action so docker and other java stuff wouldn't effect anything. 100% compatible and fixes this issue since madhead cant do anything about it, godspeed https://github.com/BrycensRanch/read-properties-action |
If JAVA_HOME is set on the runner to something other than the default, the action fails with:
ERROR: JAVA_HOME is set to an invalid directory: /opt/hostedtoolcache/Java_Adopt_jdk/11.0.11-9/x64
Removing the Set up JDK 11 step allows the workflow to proceed without issue.
Sample workflow causing the error:
The text was updated successfully, but these errors were encountered: