cake-build / cake-build/cake

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

Open
#4,402 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.2k
Forks
778
Avg merge
1h 15m
Merged PRs (30d)
19

Description

### Prerequisites

- [X] I have written a descriptive issue title
- [X] I have searched [issues](https://github.com/cake-build/cake/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)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure on macOS arm64 with the Cake.Git addin and compare the binaries under tools/Addins/Cake.Git.4.0.0/lib/net8.0/ and runtimes/osx-arm64/native/. Trace how the addin loads libgit2-a2bde63.dylib; done means the compatible runtime-specific binary loads automatically without manual replacement.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.