libgit2 / libgit2/libgit2sharp

AWS Lambda - Unable to load library

未關閉
#1,823 2 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
C#
星號
3.5k
分支
925
PR 合併指標
30 天內沒有已合併 PR

描述

Reproduction steps

dotnet tool install -g Amazon.Lambda.Tools
dotnet new --install Amazon.Lambda.Templates
dotnet new lambda.EmptyFunction --name LambdaGit
cd LambdaGit/src/LambdaGit
dotnet add package LibGit2Sharp --version 0.27.0-preview-0034
--- add "new LibGit2Sharp.Repository();" in "FunctionHandler" function in "Function.cs"
dotnet lambda deploy-function LambdaGit --function-role LambdaGitRole
dotnet lambda invoke-function LambdaGit --payload "LambdaOK"

Actual behavior

Payload:
{
"errorType": "TypeInitializationException",
"errorMessage": "The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.",
"stackTrace": [
"at LibGit2Sharp.Core.NativeMethods.git_repository_new(git_repository*& repo)",
"at LibGit2Sharp.Core.Proxy.git_repository_new()",
"at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter)",
"at lambda_method(Closure , Stream , Stream , LambdaContextInternal )"
],
"cause": {
"errorType": "DllNotFoundException",
"errorMessage": "Unable to load shared library 'git2-ef5a385' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgit2-ef5a385: cannot open shared object file: No such file or directory",
"stackTrace": [
"at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()",
"at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()",
"at LibGit2Sharp.Core.NativeMethods..cctor()"
]
}
}

Log Tail:
START RequestId: 0e940c07-4526-411d-9f47-ffbfc2cd3a73 Version: $LATEST
The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.: TypeInitializationException
at LibGit2Sharp.Core.NativeMethods.git_repository_new(git_repository*& repo)
at LibGit2Sharp.Core.Proxy.git_repository_new()
at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter)
at lambda_method(Closure , Stream , Stream , LambdaContextInternal )

at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
at LibGit2Sharp.Core.NativeMethods..cctor()

END RequestId: 0e940c07-4526-411d-9f47-ffbfc2cd3a73
REPORT RequestId: 0e940c07-4526-411d-9f47-ffbfc2cd3a73 Duration: 702.47 ms Billed Duration: 800 ms Memory Size: 256 MB Max Memory Used: 69 MB Init Duration: 156.11 ms

Version of LibGit2Sharp (release number or SHA1)

I tested all 84 available versions of GitLib2Sharp on Nuget. None of them worked.

Operating system(s) tested; .NET runtime tested

Amazon Linux 2
.NET Platform: 3.1

I analyzed several related issues in the GitLib2Sharp, aws-lambda-dotnet and Docker repositories but I was unable to solve this problem.

Please help me.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 issue 中的重現開始,尤其是 Function.cs 及其 FunctionHandler,使用 Amazon.Lambda.Tools 部署和 LibGit2Sharp 0.27.0-preview-0034 套件。透過 NativeMethods.InitializeNativeLibrary 追蹤失敗,並將已部署的 Lambda 環境與回報的 DllNotFoundException 進行比較。當已部署的函式能夠建構 LibGit2Sharp.Repository 並成功呼叫,且不再出現原生程式庫錯誤時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
aws, csharp
領域
backend, cloud
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。