2.8-rc-1 regression related to Grgit plugin

I seem to have hit some daemon related issue with my project after upgrading to 2.8-rc-1. Sometimes (I haven’t figured out what the conditions are yet) I will get an error like the following:

ew@ew-pc-3:~/dev/foo$ ./gradlew check
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test UP-TO-DATE
:buildSrc:check UP-TO-DATE
:buildSrc:build UP-TO-DATE

FAILURE: Build failed with an exception.

* Where:
Script '/home/ew/dev/foo/gradle/heroku.gradle' line: 55

* What went wrong:
A problem occurred evaluating script.
> Failed to apply plugin [id 'org.ajoberstar.grgit']
   > No signature of method: static org.ajoberstar.grgit.Grgit.open() is applicable for argument types: (java.util.LinkedHashMap) values: [[currentDir:/home/ew/dev/foo]]
     Possible solutions: open(), open(java.io.File), open(java.lang.String), open(java.io.File, org.ajoberstar.grgit.Credentials), open(java.lang.String, org.ajoberstar.grgit.Credentials), grep()

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 0.836 secs

After that occurs every successive build fails with the same error until I stop the daemon. After stopping the daemon following builds don’t fail with that error anymore:

ew@ew-pc-3:~/dev/foo$ ./gradlew --stop
Stopping daemon(s).
Gradle daemon stopped.
ew@ew-pc-3:~/dev/foo$ ./gradlew check
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test UP-TO-DATE
:buildSrc:check UP-TO-DATE
:buildSrc:build UP-TO-DATE
:codenarcBrowserTest UP-TO-DATE
:codenarcMain
:codenarcTest
:compileJava UP-TO-DATE
:compileGroovy
:assetCompile UP-TO-DATE
:writeVersion UP-TO-DATE
:processResources
:classes
...

Please let me know if there is any more information I can provide that would be useful for investigating the issue.

Thanks! We’ll take a look. Do you have a run with --stacktrace?

And which version of gradle-git are you using and which was the last Gradle version that worked?

Hi @erdi, we suspect this may have something to do with our upgrade to Groovy 2.4.4 in 2.8-rc-1. I’d like to see if I can pin that down. Any of the following would help (especially #3):

  1. The output of a failed build run with --stacktrace
  2. Version of gradle-git being used and last known good version of gradle
  3. A small project that can (or at least should be able to reproduce it)

If #3 is not feasible for you, even copy and pasting the relevant chunk of build logic that invokes Grgit.open would be a good for a start.

Thanks!

You are lucky @cbeams because it has just happened to me again. Here comes the stacktrace:

ew@ew-pc-3:~/dev/foo$ ./gradlew check --stacktrace
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test UP-TO-DATE
:buildSrc:check UP-TO-DATE
:buildSrc:build UP-TO-DATE

FAILURE: Build failed with an exception.

* Where:
Script '/home/ew/dev/foo/gradle/heroku.gradle' line: 55

* What went wrong:
A problem occurred evaluating script.
> Failed to apply plugin [id 'org.ajoberstar.grgit']
   > No signature of method: static org.ajoberstar.grgit.Grgit.open() is applicable for argument types: (java.util.LinkedHashMap) values: [[currentDir:/home/ew/dev/foo]]
     Possible solutions: open(), open(java.io.File), open(java.lang.String), open(java.io.File, org.ajoberstar.grgit.Credentials), open(java.lang.String, org.ajoberstar.grgit.Credentials), grep()

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating script.
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$1.run(DefaultScriptPluginFactory.java:148)
	at org.gradle.configuration.DefaultScriptTarget.addConfiguration(DefaultScriptTarget.java:69)
	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:153)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyScript(DefaultObjectConfigurationAction.java:101)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$000(DefaultObjectConfigurationAction.java:35)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$1.run(DefaultObjectConfigurationAction.java:61)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:135)
	at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
	at org.gradle.api.plugins.PluginAware$apply.call(Unknown Source)
	at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
	at org.gradle.api.Script$apply.callCurrent(Unknown Source)
	at build_83peyt4xfx1odmw9mjaoqyf42.run(/home/ew/dev/foo/build.gradle:25)
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$1.run(DefaultScriptPluginFactory.java:148)
	at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:72)
	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:153)
	at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
	at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
	at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:498)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:86)
	at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
	at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
	at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:125)
	at org.gradle.internal.Factories$1.create(Factories.java:22)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:122)
	at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
	at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
	at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
	at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
	at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
	at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
	at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:77)
	at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:47)
	at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
	at org.gradle.util.Swapper.swap(Swapper.java:38)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:71)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
	at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
	at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'org.ajoberstar.grgit']
	at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:160)
	at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:112)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:112)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:35)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:79)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:135)
	at org.gradle.groovy.scripts.DefaultScript.apply(DefaultScript.java:109)
	at org.gradle.api.Script$apply.callCurrent(Unknown Source)
	at heroku_5tgjg3w39likl9vx2m8onecvo.run(/home/ew/dev/foo/gradle/heroku.gradle:55)
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
	... 71 more
Caused by: groovy.lang.MissingMethodException: No signature of method: static org.ajoberstar.grgit.Grgit.open() is applicable for argument types: (java.util.LinkedHashMap) values: [[currentDir:/home/ew/dev/foo]]
Possible solutions: open(), open(java.io.File), open(java.lang.String), open(java.io.File, org.ajoberstar.grgit.Credentials), open(java.lang.String, org.ajoberstar.grgit.Credentials), grep()
	at org.ajoberstar.gradle.git.base.GrgitPlugin.apply(GrgitPlugin.groovy:31)
	at org.ajoberstar.gradle.git.base.GrgitPlugin.apply(GrgitPlugin.groovy)
	at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
	at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:44)
	at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
	... 80 more


BUILD FAILED

Total time: 0.594 secs

This happens on at least two machines (one Mac and one Ubuntu) but not on all machines used in the project. I haven’t seen this happening with Gradle 2.7.

Wrt a project that could (potentially) be used to reproduce then it looks to me like a project with git initialized for the root directory and the following in the build script should be enough:

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "org.ajoberstar:gradle-git:1.2.0"
    }
}

apply plugin: "org.ajoberstar.grgit"

You could probably substitute it with applying that plugin using the new dsl but this is how I’m applying that plugin in the project where the failure occurs. There is 1.3.0 version available for that plugin, I’m wondering if I should upgrade… I’m also wondering if I it’s possible that I somehow ended up with having two versions of org.ajoberstar.grgit.Grgit on the build script classpath, so just in case, this is my whole buildscript block:

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "io.ratpack:ratpack-gradle:1.0.0"
        classpath "org.ajoberstar:gradle-git:1.2.0"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.5.8"
        classpath "com.bertramlabs.plugins:less-asset-pipeline:2.5.4"
    }
}

Shout if you need more info from me.

This is excellent, thanks. Will do.

Marcin, take a look at https://github.com/cbeams/gradle-repro/commit/542567. Could you fork that repo and see if you can do anything to get the project at https://github.com/cbeams/gradle-repro/tree/master/T-11953 to fail?

Note that I did try to add the additional dependencies as you suggested, and it made no difference. Also, I see from the original “No signature matching…” error above that you appear to be calling Grgit.open as follows: Grgit.open(currentDir: '/home/ew/dev/foo'). As you can see in the repro project, I’m doing something quite similar, but using the dir: key vs. the currentDir: key. It makes no difference either way (the build always succeeds for me), but it is worth noting that IDEA raises a warning on this syntax: .

The #open(File) variant of the method, while deprecated, does not raise this same warning in IDEA:

And the no-arg, non-deprecated #open variant has no issues at all:

So if you are indeed able to reproduce the issue based on the repro project above, it’ll be interesting to see if changing the signature used solves the problem.

Chris, please note that the failure occurs when applying the plugin and not when calling Grgir.open() directly from my code - one of the causes in the stacktrace is org.gradle.api.internal.plugins.PluginApplicationException. Your test project does not apply the plugin even though I suggested doing so in the snippet I provided.

Thinking of it, I think I saw it failing after a commit or checkout, let me play with it a bit.

No, that was a red herring, no amount of switching branches, committing or merging would trigger it…

Also, I was not able to reproduce on your project. I would suggest introducing some significant delay between running the build(tens of minutes? an hour?) when trying to reproduce.

Oops, I should have caught the apply plugin statement of course. I’ll fix that up and try introducing delays, and see what else I can do to track this down.

It happened to me again, the second time today. I don’t have time to investigate now but will spend some time after work to see if I can figure out what’s going on there.

Actually, I’m onto something here. Will write up fully in a moment, but in the meantime, is there any chance you’re working against the same daemon with multiple gradle projects, each using a different version of grgit—namely, a version of grgit >= 1.3.0?

Hi Marcin!

In order to eliminate more options, any chance you can build this branch and test against it?

https://github.com/gradle/gradle/tree/cc-groovy-245

Basically it’s an upgrade to Groovy 2.4.5 with a removal of a memory leak strategy prevention in some cases (because no longer needed).

Thanks a lot!

I was actually thinking if that’s the case… It’s possible that I do (would need to check several projects I worked on since last week when this started to happen) on my own machine and definitely not on my work machine because we only ever build a single project. I’m not sure that this is the reason of the failure I’m getting as it happens both on my home mac and work ubuntu.

The problem is intermittent which would mean that to be order to rule it out that way I would need to run it for a day or so… I can try but you wouldn’t get a response before tomorrow evening.

I’m wondering if we should move the conversation to a separate topic? This might be a bit too noisy for others here…

Ok, I can confirm that you don’t need to run multiple projects for this to occur. I’ve only run this project since stopping the daemon last time and it has reoccurred just now.

Thanks. @sterling has since reported he was able to repro this issue last night, with exactly this script and steps: https://github.com/cbeams/gradle-repro/commit/7bd95e3. I’m currently in the middle of step #5, with fingers crossed :smile:

Yes, if we don’t have an answer after this current repro attempt, I’ll see about moving the conversation elsewhere.

I’ve just checked what #5 is, ROTFL.

Dying to know what the issue was if you really get it reproduced by waiting for an hour!