11

I have this simple build script:

import org.ajoberstar.grgit.Grgit

apply plugin: 'application'
apply plugin: 'org.ajoberstar.release-opinion'

task wrapper(type:Wrapper) {
    gradleVersion = '2.1'
}

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'org.ajoberstar:gradle-git:0.11.+'
  }
}

release {
  grgit = Grgit.open(project.file('.'))
}

I created a HelloWorld style project and initialized the git repository. When I use a directory for the remote origin I can run

.\gradlew.bat release

just fine. But when I use an ssh target for the remote origin I get the following output:

16:39:55.355 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':prepare'.
16:39:55.355 [INFO] [org.gradle.api.Task] Fetching changes from remote: origin
16:39:55.387 [INFO] [org.ajoberstar.grgit.auth.TransportOpUtil] The following authentication options are allowed (though they may not be available): [
HARDCODED, PAGEANT, SSHAGENT, INTERACTIVE]
16:39:55.402 [INFO] [org.ajoberstar.grgit.auth.TransportOpUtil] using interactive credentials, if needed
16:39:55.480 [INFO] [org.ajoberstar.grgit.auth.JschAgentProxySessionFactory] ssh-agent not available
16:39:55.511 [INFO] [org.ajoberstar.grgit.auth.JschAgentProxySessionFactory] pageant available
16:39:55.527 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':prepare'
16:39:55.527 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :prepare FAILED
16:39:55.543 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :prepare (Thread[main,5,main]) completed. Took 0.219 secs.
16:39:55.543 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 0.219 secs, idle: 0.0
 secs
16:39:55.543 [ERROR] [org.gradle.BuildExceptionReporter]
16:39:55.543 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
16:39:55.543 [ERROR] [org.gradle.BuildExceptionReporter]
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':prepare'.
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] >
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter]
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter]   There is an incompatible JNA native library installed on this system.
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter]   To resolve this issue you may do one of the following:
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter]    - remove or uninstall the offending library
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter]    - set the system property jna.nosys=true
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter]    - set jna.boot.library.path to include the path to the version of the
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter]      jnidispatch library included with the JNA jar file you are using
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter]
16:39:55.574 [ERROR] [org.gradle.BuildExceptionReporter]
16:39:55.574 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
16:39:55.574 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
16:39:55.574 [LIFECYCLE] [org.gradle.BuildResultLogger]
16:39:55.574 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED

I reran with --stacktrace and here is the partial stack trace for this error (seems to implicate Jsch):

Caused by: java.lang.Error:
    at com.sun.jna.Native.<clinit>(Native.java:142)
    at com.jcraft.jsch.agentproxy.connector.PageantConnector$User32.<clinit>(PageantConnector.java:85)
    at com.jcraft.jsch.agentproxy.connector.PageantConnector.<init>(PageantConnector.java:61)
    at org.ajoberstar.grgit.auth.JschAgentProxySessionFactory$_closure2.doCall(JschAgentProxySessionFactory.groovy:122)
    at org.ajoberstar.grgit.auth.JschAgentProxySessionFactory$_closure2.doCall(JschAgentProxySessionFactory.groovy)
    at org.ajoberstar.grgit.auth.JschAgentProxySessionFactory$_determineConnector_closure5.doCall(JschAgentProxySessionFactory.groovy:86)
    at org.ajoberstar.grgit.auth.JschAgentProxySessionFactory.determineConnector(JschAgentProxySessionFactory.groovy:85)
    at org.ajoberstar.grgit.auth.JschAgentProxySessionFactory.getJSch(JschAgentProxySessionFactory.groovy:65)
    at org.eclipse.jgit.transport.JschConfigSessionFactory.createSession(JschConfigSessionFactory.java:191)
    at org.eclipse.jgit.transport.JschConfigSessionFactory.createSession(JschConfigSessionFactory.java:150)
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:109)
    at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
    at org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init>(TransportGitSsh.java:306)
    at org.eclipse.jgit.transport.TransportGitSsh.openPush(TransportGitSsh.java:152)
    at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:154)
    at org.eclipse.jgit.transport.Transport.push(Transport.java:1173)
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:156)
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:79)
    at java_util_concurrent_Callable$call$0.call(Unknown Source)
    at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy:104)
    at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy)
    at java_util_concurrent_Callable$call.call(Unknown Source)
    at java_util_concurrent_Callable$call.call(Unknown Source)
    at org.ajoberstar.grgit.util.OpSyntaxUtil.tryOp(OpSyntaxUtil.groovy:45)
    at org.ajoberstar.grgit.Grgit.methodMissing(Grgit.groovy:190)
    at org.ajoberstar.gradle.git.release.GrgitReleasePlugin$_addReleaseTask_closure4_closure14.doCall(GrgitReleasePlugin.groovy:134)
    ... 56 more

Any ideas on how to get this working?

I'm using Gradle 2.1, Gradle-git 0.11.0 (as you can see in the build script), Java 1.7.0_71 64-bit (there are other versions of Java on the system, but the PATH is set for this version and java -version outputs 1.7.0_71 64 bit), Putty 0.60, and git 1.9.0 msysgit.

Jason
  • 11,709
  • 9
  • 66
  • 82
  • Which of the suggestions in the error message did you try? – technomage Oct 21 '14 at 02:44
  • 1
    Ah yes, so that's part of my problem... how do I know which library is the offending library? And where is that library located on my filesystem? How do I know which Jar has a JNA library? I did try the second suggestion: setting jna.nosys=true and nothing changed. Also, Gradle sets the jna.boot.library.path so that its specific jnidispatch library is used, so it's unclear to me if another jar has another dispatch library or not. – Jason Oct 23 '14 at 15:32
  • Not sure why Gradle ships with an extracted jnidispatch.dll. I'd say removing the jna.boot.library.path is worth a try (if that's set jna.nosys is ignored) – user2543253 Oct 23 '14 at 16:32
  • Ah, I didn't know that setting jna.boot.library.path overrides setting jna.nosys, thanks! I'm not sure gradle ships with it... maybe it just sets the location where it should be stored on the filesystem. You'll find it in /home/user/.gradle/native/jna/your_os/ (using the appropriate /home/user and "your_os" directories). jna.boot.library.path is set in the Gradle source code in gradle-1.9/src/native/org/gradle/internal/nativeplatform/jna/JnaBootPathConfigurer.java – Jason Oct 23 '14 at 22:59
  • Maybe you could try to unset the property again after initialization is done. Or you could try to give both components the same version of JNA, although that might not work depending on what functions are used (JNA has some incompatible changes since 3.2.7) – user2543253 Oct 24 '14 at 09:31
  • Starting your VM with `-Djna.debug_load.jna=true` will show you where JNA is looking and what it finds. – technomage Nov 07 '14 at 12:12
  • Did you find anything for this? I have the same problem! – Jean-François Côté Mar 09 '15 at 19:11
  • I have not fixed this problem. I just avoid windows. – Jason Mar 10 '15 at 19:46

1 Answers1

2

Some possible reasons for this are:

  • There was at least one bug in Gradle where the Gradle-side JNA "leaked" into other places, see https://issues.gradle.org/browse/GRADLE-3288, however it mainly was in RC-versions of Gradle 2.4
  • I had one case where I did pass system properties from Gradle to the unit test via

    test { systemProperties = System.properties }

This leads to Gradle passing JNA-system properties on to the unit test. This was solved for me by the following:

test {
    systemProperties = System.properties

    systemProperties['jna.boot.library.path'] = null
}
centic
  • 15,565
  • 9
  • 68
  • 125