libgit2 / libgit2/libgit2sharp
TypeInitializationException on M1 chip
未关闭
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 3.5k
- 派生
- 925
- PR 合并指标
- 30 天内没有已合并 PR
描述
Reproduction steps
I had a bug report on my project about this.
this is the code that's failing on an M1 chip.
public static void GitSetup(string solutionDirectory)
{
GitBuilder.CreateGitIgnore(solutionDirectory);
Repository.Init(solutionDirectory);
var repo = new Repository(solutionDirectory);
string[] allFiles = Directory.GetFiles(solutionDirectory, "*.*", SearchOption.AllDirectories);
Commands.Stage(repo, allFiles);
var author = new Signature("Craftsman", "craftsman", DateTimeOffset.Now);
repo.Commit("Initial Commit", author, author);
}
Expected behavior
I should have a new repo created and an initial commit made. This works fine on my intel chip.
Actual behavior
This is the exception that gets thrown
TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an
exception.
In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment
variable: dlopen(libgit2-106a5f2, 0x0001): tried: 'libgit2-106a5f2' (no such file),
'/usr/local/lib/libgit2-106a5f2' (no such file), '/usr/lib/libgit2-106a5f2' (no such file),
'/Users/me/Desktop/code/csharp/libgit2-106a5f2' (no such file),
'/usr/local/lib/libgit2-106a5f2' (no such file), '/usr/lib/libgit2-106a5f2' (no such file)
at git_libgit2_init()
at InitializeNativeLibrary()
at cctor()
at git_repository_init_ext(git_repository*& repository, FilePath path, GitRepositoryInitOptions options)
at git_repository_init_ext(FilePath workdirPath, FilePath gitdirPath, Boolean isBare)
at Init(String path, Boolean isBare)
at Init(String path)
at GitSetup(String solutionDirectory) in Utilities.cs:393
at CreateNewDomainProject(String domainDirectory, IFileSystem fileSystem, DomainProject domainProject)
in NewDomainProjectCommand.cs:115
at Run(String buildSolutionDirectory, IFileSystem fileSystem) in NewExampleCommand.cs:41
Version of LibGit2Sharp (release number or SHA1)
Release: 0.26.2
Operating system(s) tested; .NET runtime tested
OS + .NET version
.NET SDK (reflecting any global.json):
Version: 6.0.101
Commit: ef49f6213a
Runtime Environment:
OS Name: Mac OS X
OS Version: 12.1
OS Platform: Darwin
RID: osx.12-arm64
Base Path: /usr/local/share/dotnet/sdk/6.0.101/
Host (useful for support):
Version: 6.0.1
Commit: 3a25a7f1cc
.NET SDKs installed:
6.0.101 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
git version
❯ git --version
git version 2.34.1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 Utilities.cs 中的 GitSetup,在报告的 macOS 12.1 arm64 环境中重现该故障,然后检查 LibGit2Sharp.Core.NativeMethods 以及经过 NewDomainProjectCommand.cs 和 NewExampleCommand.cs 的调用路径。当 Repository.Init 和初始 commit 在 M1 芯片上成功完成且不出现 TypeInitializationException 时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100