[GRADLE-2995] Gradle Exec task hangs when setting the environment property Created: 20/Jan/14 Updated: 10/Feb/17 Resolved: 10/Feb/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Task | ||
Reporter: | Gradle Forums | Assignee: | Unassigned |
Resolution: | Won't Fix | Votes: | 0 |
Description |
Executing the following task, within a subproject, ... task makeTree(type: Exec) { Fails, as expected, because the script being called requires specific environment settings. $ gradlew makeTree FAILURE: Build failed with an exception.
BUILD FAILED Total time: 7.369 secs However, when providing the environment for this task, gradlew hangs, indefinitely. Code: task makeTree(type: Exec) { Result: $ gradlew makeTree The task is specific to Windows, so I've only reproduced this on two different Windows 7 machines, both using the gradle 1.9 wrapper. One with JDK 1.7 and the other with JDK 1.6. I also verified that I'm setting the environment property, correctly, by passing the current environment: environment System.getenv() and the task executes, as expected. So, there is something wrong with the environment map, which I'm passing in, that seems to get gradle (or something deeper) into a bad state. Any ideas? Should I debug deeper? |
Comments |
Comment by Gradle Forums [ 20/Jan/14 ] |
You'll have to dig deeper. Run with `--debug`, try to figure out where the task hangs (maybe in your script?), get a thread dump, inspect the map that you are passing in, try to convert all map keys and values to strings beforehand, etc. |
Comment by Gradle Forums [ 20/Jan/14 ] |
Yeah, after reading my post, I knew that I needed to spend more time on this. I did verify that it isn't the script. I know that it is within the task execution of gradle. I verified by simply changing to the commandLine to execute a simple windows 'dir' command. |
Comment by Gradle Forums [ 20/Jan/14 ] |
I switched to a simple 'dir' command, in order to eliminate any doubt. Here is what I see with --debug: 15:21:02.489 [INFO] [org.gradle.process.internal.DefaultExecHandle] Starting process 'command 'cmd''. Working directory: D:\repos\xxx Command: cmd /c dir for environment, see http://pastebin.com/hnHdwxD1 ... |
Comment by Gradle Forums [ 20/Jan/14 ] |
Okay...after digging deeper...I kept adding environment variables until I encountered the issue...and it was user error...my error, as environment variable names should not contain equal signs. But, this still shouldn't hang, right? Also, I have a slight gripe about the pretty printing of the environment map in the gradle debug output. Read on... *For your thorough understanding and reading enjoyment.* The issue was with a regex of mine not accounting for environment variable's with equals signs in the variable's value. I was accidentally capturing the equals as a part of the environment variable's name. Gripe #1 It wasn't easy to see the equals sign in the variable name, in the gradle debug output. This appears to be because the environment isn't printed in groovy map notation. E.g. gradle's debug output doesn't really distinguish which equals represents the beginning of the environment variable's value and which is a part of the value. After all, it is valid to have an equals sign as a part of a variable's value. From gradle's debug output: ...PROCESSOR_LEVEL=6, VC_VER=VC_VERSION=10.0, PLATFORM=X64.... From printing the groovy map, I can clearly see that 'VC_VER=VC_VERSION' is an invalid environment variable name (damn greedy .* in my regex). ...NUMBER_OF_PROCESSORS:4, SYSTEMROOT:C:\Windows, VC_VER=VC_VERSION:10.0] Gripe #2 The task hangs when the environment variable contains an equals sign in the name. I will admit invalid user input, but this can't be acceptable behavior, can it? A reproducible test case: def isWindows = System.properties['os.name'].toLowerCase().contains('windows') task someTask(type: Exec) { Hangs... $ gradle someTask All that being said, I still love Gradle! |
Comment by Benjamin Muschko [ 15/Nov/16 ] |
As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! |
Comment by Benjamin Muschko [ 10/Feb/17 ] |
Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved. |