allegro / axion-release-plugin

Gradle release & version management plugin.
https://axion-release-plugin.readthedocs.io/
Apache License 2.0
559 stars 154 forks source link

Pushing via SSH not working on Apple Silicon (M1) (ARM64) (aarch64) #630

Closed cliffred closed 8 months ago

cliffred commented 1 year ago

The release task fails on pushing to git when using SSH on a Mac with M1 processor. fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64') in the output suggests that the M1 processor is the cause. Java Native Access (JNA) is used and the version on the build path is net.java.dev.jna:jna:4.1.0, transitively via jsch agentproxy. Support for Mac aarch64 was added in 5.7.0. So upgrading the version fixed the issue:

buildscript {
    dependencies{
        classpath("net.java.dev.jna:jna:5.13.0")
    }
}

I'm not sure if simply adding a new version of jna to the dependencies of axion is without risks, as it is a major upgrade, and jsch does not seem to be maintained anymore. But otherwise this workaround could perhaps be added to the docs?

Output:

> Task :release FAILED
Creating tag: 4.0.1
Pushing all to remote: origin
Failed to use ssh-agent as identity provider, see debug logs for details
Exception occurred during push: org.eclipse.jgit.api.errors.TransportException: git@github.com:cliffred/temp.git: Auth fail

Stack trace:

[pl.allegro.tech.build.axion.release.infrastructure.git.SshAgentIdentityRepositoryFactory] java.lang.NoClassDefFoundError: Could not initialize class com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory$CLibrary
        at com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory.open(JNAUSocketFactory.java:114)
        at com.jcraft.jsch.agentproxy.connector.SSHAgentConnector.open(SSHAgentConnector.java:93)
        at com.jcraft.jsch.agentproxy.connector.SSHAgentConnector.<init>(SSHAgentConnector.java:54)
        at com.jcraft.jsch.agentproxy.connector.SSHAgentConnector.<init>(SSHAgentConnector.java:44)
        at pl.allegro.tech.build.axion.release.infrastructure.git.SshAgentIdentityRepositoryFactory.trySshAgent(SshAgentIdentityRepositoryFactory.java:85)
        at pl.allegro.tech.build.axion.release.infrastructure.git.SshAgentIdentityRepositoryFactory.tryToCreateIdentityRepository(SshAgentIdentityRepositoryFactory.java:34)
        at pl.allegro.tech.build.axion.release.infrastructure.git.SshConnector.createSshAgentBasedJSch(SshConnector.java:49)
        at pl.allegro.tech.build.axion.release.infrastructure.git.SshConnector.getJSch(SshConnector.java:31)
        at org.eclipse.jgit.transport.ssh.jsch.JschConfigSessionFactory.createSession(JschConfigSessionFactory.java:337)
        at org.eclipse.jgit.transport.ssh.jsch.JschConfigSessionFactory.createSession(JschConfigSessionFactory.java:204)
        at org.eclipse.jgit.transport.ssh.jsch.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
        at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:107)
        at org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init>(TransportGitSsh.java:358)
        at org.eclipse.jgit.transport.TransportGitSsh.openPush(TransportGitSsh.java:159)
        at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:138)
        at org.eclipse.jgit.transport.Transport.push(Transport.java:1537)
        at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:158)
        at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.callPush(GitRepository.java:182)
        at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.push(GitRepository.java:177)
        ...
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: /Users/cliffred/Library/Caches/JNA/temp/jna11994391166393577542.tmp: dlopen(/Users/cliffred/Library/Caches/JNA/temp/jna11994391166393577542.tmp, 0x0001): tried: '/Users/cliffred/Library/Caches/JNA/temp/jna11994391166393577542.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/cliffred/Library/Caches/JNA/temp/jna11994391166393577542.tmp' (no such file), '/Users/cliffred/Library/Caches/JNA/temp/jna11994391166393577542.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64')) [in thread "Execution worker"]
        at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
        ...
        at com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory$CLibrary.<clinit>(JNAUSocketFactory.java:47)
        at com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory.open(JNAUSocketFactory.java:114)
        at com.jcraft.jsch.agentproxy.connector.SSHAgentConnector.open(SSHAgentConnector.java:93)
        at com.jcraft.jsch.agentproxy.connector.SSHAgentConnector.<init>(SSHAgentConnector.java:54)
        at com.jcraft.jsch.agentproxy.connector.SSHAgentConnector.<init>(SSHAgentConnector.java:44)
        at pl.allegro.tech.build.axion.release.infrastructure.git.SshAgentIdentityRepositoryFactory.trySshAgent(SshAgentIdentityRepositoryFactory.java:85)
        at pl.allegro.tech.build.axion.release.infrastructure.git.SshAgentIdentityRepositoryFactory.tryToCreateIdentityRepository(SshAgentIdentityRepositoryFactory.java:34)
        at pl.allegro.tech.build.axion.release.infrastructure.git.SshConnector.createSshAgentBasedJSch(SshConnector.java:49)
        at pl.allegro.tech.build.axion.release.infrastructure.git.SshConnector.getJSch(SshConnector.java:31)
        at org.eclipse.jgit.transport.ssh.jsch.JschConfigSessionFactory.createSession(JschConfigSessionFactory.java:337)
        ... 122 more
bgalek commented 8 months ago

Should be working now