Skip to content

Cake.Git Addin Fails to Load Native Binaries on macOS (arm64) #4402

@bostonaqua

Description

@bostonaqua

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

Cake runner

Cake .NET Tool

Cake version

All

Operating system

macOS

Operating system architecture

Arm64

CI Server

No response

What are you seeing?

When using the Cake.Git addin on macOS (arm64), the required native binary libgit2-a2bde63.dylib fails to load. The addin attempts to load a binary from the default location (tools/Addins/Cake.Git.4.0.0/lib/net8.0/) that is built for the x64 architecture, which is incompatible with macOS arm64.

However, a compatible binary is included in the package at tools/Addins/Cake.Git.4.0.0/runtimes/osx-arm64/native/libgit2-a2bde63.dylib. Manually replacing the default binary with the binary provided in the "runtimes" directory resolves the issue.

What is expected?

The Cake should automatically detect and load the appropriate native binary for the target runtime and architecture at least for Cake.Git. On macOS arm64, it should load the binary from runtimes/osx-arm64/native/libgit2-a2bde63.dylib instead of using the incompatible x64 binary from lib/net8.0/.

Steps to Reproduce

  1. Use a Mac device with an M-series chip (arm64 architecture).
  2. Create a Cake script that uses the Cake.Git addin.
  3. Execute the script with the any supported .NET runtime.
  4. Observe the error when the addin attempts to load git2-a2bde63.dylib or libgit2-a2bde63.dylib.

Optional:

  • Manually replace the binary in lib/net8.0/ with the one in runtimes/osx-arm64/native/ to confirm that it resolves the issue.

Output log

Error: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'git2-a2bde63' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: 
dlopen(/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63.dylib, 0x0001): tried: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63.dylib' (no such file), '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63.dylib' (no such file)
dlopen(/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63.dylib, 0x0001): tried: '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63.dylib' (no such file), '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63.dylib' (no such file)
dlopen(git2-a2bde63.dylib, 0x0001): tried: 'git2-a2bde63.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSgit2-a2bde63.dylib' (no such file), '/usr/lib/git2-a2bde63.dylib' (no such file, not in dyld cache), 'git2-a2bde63.dylib' (no such file), '/usr/local/lib/git2-a2bde63.dylib' (no such file), '/usr/lib/git2-a2bde63.dylib' (no such file, not in dyld cache)
dlopen(/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63.dylib, 0x0001): tried: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63.dylib' (no such file), '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63.dylib' (no such file)
dlopen(/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63.dylib, 0x0001): tried: '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63.dylib' (no such file), '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
dlopen(libgit2-a2bde63.dylib, 0x0001): tried: 'libgit2-a2bde63.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibgit2-a2bde63.dylib' (no such file), '/usr/lib/libgit2-a2bde63.dylib' (no such file, not in dyld cache), 'libgit2-a2bde63.dylib' (no such file), '/usr/local/lib/libgit2-a2bde63.dylib' (no such file), '/usr/lib/libgit2-a2bde63.dylib' (no such file, not in dyld cache)
dlopen(/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63, 0x0001): tried: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63' (no such file), '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63' (no such file)
dlopen(/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63, 0x0001): tried: '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63' (no such file), '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63' (no such file)
dlopen(git2-a2bde63, 0x0001): tried: 'git2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OSgit2-a2bde63' (no such file), '/usr/lib/git2-a2bde63' (no such file, not in dyld cache), 'git2-a2bde63' (no such file), '/usr/local/lib/git2-a2bde63' (no such file), '/usr/lib/git2-a2bde63' (no such file, not in dyld cache)
dlopen(/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63, 0x0001): tried: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63' (no such file), '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63' (no such file)
dlopen(/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63, 0x0001): tried: '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63' (no such file), '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63' (no such file)
dlopen(libgit2-a2bde63, 0x0001): tried: 'libgit2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibgit2-a2bde63' (no such file), '/usr/lib/libgit2-a2bde63' (no such file, not in dyld cache), 'libgit2-a2bde63' (no such file), '/usr/local/lib/libgit2-a2bde63' (no such file), '/usr/lib/libgit2-a2bde63' (no such file, not in dyld cache)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions