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
Gradle hangs in Xcode pre-build actions #15941
Comments
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution. |
This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to to let know so we can reopen the issue. Please try to provide steps to reproduce, a quick explanation of your use case or a high-quality pull request. |
Please reopen |
I hate it that noone answered in the ticket and the ticket is closed due to inactivity. |
Sorry about that @alistra. I'm reopening the issue. |
Yes both on newest stable Xcode 13 & Xcode 14 beta |
I can also confirm it's still an issue and it's really an annoying one. |
Could one of you provide the Gradle daemon logs at the time of the hang? |
I don't know which part of the log is relevant tbh |
Here's mine: daemon-22105.out.log |
Thank you both. @lacasseio, does it ring a bell? |
I think I remember seeing something similar to that and if I remember correctly it has to do with the daemon. Try using From what I remember, Xcode wants to wait for all process started to exit. In some scenario, the execution reuse a daemon which is ignored by Xcode and does not hang. However, in other scenario a new daemon may be spawn causing Xcode to wait (hang). |
I believe at the time I was trying I am available for a playdate if you need to debug this on a machine with Xcode setup. |
I digged a bit further and found your issue when comparing to Nokee's run script for Xcode. You have to nullify the inputs, so your command has to be |
@lacasseio this in fact fixes the issue and works around the problem. Do you have any idea why this might be? Is this an Xcode issue, or just Gradle waits for input if it autodetects some condition from the environment and maybe this logic is buggy? |
Unfortunately, I didn't dig too deeply into the issue. My guess was probably having to do with how Gradle reads from the stdin and how Xcode provides the stdin to the script. I'm not aware Xcode allows inputs to be passed to run scripts. I would assume that Xcode may simply use a closed stdin (or something strange for the non-Apple world) by default which Gradle may not support (or fall into a hanging code path). Looking at the daemon logs, the daemon starts up but doesn't receive the build command, so it seems like the daemon startup procedure is at fault. Gradle swap the That is, unfortunately, as far as I can go with my diagnostic. Gradle codebase can be confusing to follow, so I couldn't find the exact code path that processes the input. I know I found it in the past as there was a bug that dropped inputs as it was reading everything available on each input process which would break things like As you mentioned, there is a bug here or an unintended side-effect. Gradle should either not hang or crash with a good error message. My general rule of thumb when writing defensive shell scripts is to null the inputs of commands I don't expect any user input processing as it better demonstrates the intent. I hope that help. |
The hint is also that it doesn't hang when you trigger the action through a button in the Xcode GUI, but it hangs when you invoke a CLI command. I'm not an expert, but similar issues when when trying to run keychain commands on a macOS Jenkins node and depending if the Jenkins was running as a |
The problem still exists in Xcode 15.1, everything works as expected in Xcode GUI, but running xcodebuild from CLI puts gradle in some kind of enless loop. This happens only if gradle is called as part of pre-build scheme action. |
Even very simple Gradle configuration hangs when being run from Xcode pre-build action running through
xcodebuild
.Bug was initially reported to Apple (response in the screenshots attached) but they identified it is an issue with Gradle.
This happens even with
gradle tasks
so it is independent of the configuration of the build process.Expected Behavior
When
gradle
is run to build something from an Xcode pre-build action step, it should finish normally, like it does when invoked from the terminal directly.Current Behavior
The gradle process hangs and the
xcodebuild
does not finish.Context
I'm trying to build a Kotlin-Multi-Platform artifact to use in my iOS app as a pre-build action step in Xcode.
Steps to Reproduce
xcodebuild archive
command line utilityYour Environment
GradlePreActionTest.zip
The text was updated successfully, but these errors were encountered: