libgit2 / libgit2/libgit2sharp

Failed to load native git library inside a powershell module

Abierto
#2,121 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
C#
Estrellas
3.5k
Forks
925
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I made a class library that uses LibGit2Sharp to perform some actions on a repository.
This class library is loaded in a console app with no problem
I'm trying to create a powershell module that uses the same class library but it seems to fails to load the git native library

I'm not too sure if the issue is coming from a badly configured project or if it's just the powershell module that fails to automatically bind the proper native dll

I get the following exception:
The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.

Stack trace:
at LibGit2Sharp.Core.NativeMethods.git_repository_open(git_repository*& repository, FilePath path)
at LibGit2Sharp.Core.Proxy.git_repository_open(String path) in //LibGit2Sharp/Core/Proxy.cs:line 2552
at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter) in /
/LibGit2Sharp/Repository.cs:line 159
at LibGit2Sharp.Repository..ctor(String path) in /_/LibGit2Sharp/Repository.cs:line 70
at ClassLibrary.Class1.Init(String path) in D:\dev\Perso\ClassLibrary\Class1.cs:line 11
at MyModule.TestSampleCmdletCommand.ProcessRecord() in D:\dev\Perso\MyModule\TestSampleCmdletCommand.cs:line 14
at System.Management.Automation.CommandProcessor.ProcessRecord() in System.Management.Automation\CommandProcessor.cs:line 200

InnerException:
Unable to load DLL 'git2-a418d9d' or one of its dependencies: The specified module could not be found. (0x8007007E)

at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary() in //LibGit2Sharp/Core/NativeMethods.cs:line 148
at LibGit2Sharp.Core.NativeMethods..cctor() in /
/LibGit2Sharp/Core/NativeMethods.cs:line 54

Reproduction steps

LibGit2SharpMiniProject.zip
https://github.com/NephChevsky/LibGit2SharpMiniProject
I created a simple project to reproduce this issue
Just launch the project with the launchSettings.json configuration and type the command: "Test-SampleCmdlet"

Expected behavior

Should find and load the right native library properly

Actual behavior

Could not load native library git2-a418d9d.dll

Version of LibGit2Sharp (release number or SHA1)

0.30.0

Operating system(s) tested; .NET runtime tested

net8
Windows 11 Professional

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduzca el fallo del LibGit2SharpMiniProject vinculado iniciándolo con launchSettings.json y ejecutando Test-SampleCmdlet. Empiece por NativeMethods.InitializeNativeLibrary en NativeMethods.cs, en la línea 148, y por la ruta de carga del módulo de PowerShell; después, verifique que la biblioteca nativa correcta y sus dependencias se carguen con el módulo igual que en la aplicación de consola.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp, git, powershell
Área
cli, tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.