Git Sync Issues

Product: PowerShell Universal
Version: 1.5.21
Version: 2.9.3
Powershell: 7.2.2
Container: Ubuntu 20.04

Trying to get our container updated to at least Powershell 7.2.2 and Ubuntu 20.04. Works great on my local machine, as always, but when I try to get it up into azure I start running into issues. I think this issue lies with LibGit2Sharp and possibly a missing dependency or incompatible version. I can get the container to run, but when in Azure I’m using Git Sync and it never pulls down my repo. I get this error.

Failed to sync: The type initializer for ‘LibGit2Sharp.Core.NativeMethods’ threw an exception. at LibGit2Sharp.Core.NativeMethods.git_repository_open_ext(git_repository*& repository, FilePath path, RepositoryOpenFlags flags, FilePath ceilingDirs)

Tried with version 1.5.21 and 2.9.3 of PSU same issue on both.

Here is my docker file for reference.

# Docker image file that describes an Ubuntu18.04 image with PowerShell installed from Microsoft APT Repo

ARG fromTag=7.2.2-ubuntu-20.04

ARG imageRepo=mcr.microsoft.com/powershell

FROM ${imageRepo}:${fromTag} AS installer-env

ARG VERSION=1.5.21

ARG PACKAGE_URL=https://imsreleases.blob.core.windows.net/universal/production/${VERSION}/Universal.linux-x64.${VERSION}.zip

ARG DEBIAN_FRONTEND=noninteractive

# Environmental Variables

ENV Data__RepositoryPath=/home/.PowerShellUniversal/Repository

ENV Data__ConnectionString=/home/.PowerShellUniversal/database.db

ENV UniversalDashboard__AssetsFolder=/home/.PowerShellUniversal/Repository/Dashboard

# Install dependencies and clean up

RUN apt-get update

RUN apt-get install openssh-server -y

RUN apt-get install -y tzdata

RUN apt-get install -y apt-utils 2>&1 | grep -v "debconf: delaying package configuration, since apt-utils is not installed"

RUN apt-get install --no-install-recommends -y \

    # curl is required to grab the Linux package

        curl \

    # less is required for help in powershell

        less \

    # requied to setup the locale

        locales \

    # required for SSL

        ca-certificates \

        gss-ntlmssp \

        libc6-dev \

    # PowerShell remoting over SSH dependencies

        openssh-client \

        unzip

    # Download the Linux package and save it

RUN apt-get install python3 -y

RUN apt-get update

RUN apt-get install python3-pip -y

RUN pip3 install IP2Location

RUN echo ${PACKAGE_URL}

RUN curl --insecure -sSL ${PACKAGE_URL} -o /tmp/universal.zip

RUN unzip /tmp/universal.zip -d ./etc/Universal || :

    # remove powershell package

RUN rm /tmp/universal.zip

RUN chmod +x ./etc/Universal/Universal.Server

# Install OpenSSH and set the password for root to "Docker!".

RUN mkdir -p /run/sshd

RUN echo "root:Docker!" | chpasswd

# Install PSWSMan - for Exchange Powershell Connections

RUN pwsh -C "Install-Module -Name PSWSMan -Force -Scope AllUsers"

RUN pwsh -C "Install-WSMan"

# Copy the sshd_config file to the /etc/ssh/ directory

COPY sshd_config /etc/ssh/

COPY init_container.sh ./

RUN chmod 755 ./init_container.sh

# Port to expose

EXPOSE 5000 2222

# Path to execute

ENTRYPOINT "./init_container.sh"

It certainly looks like something is up with LibGit2Sharp. I’ll have to spin up a docker container and let you know what I find. I’ll open an issue for this.

Thanks @adam. Any ideas or things I should try to hopefully work around it? I’m guessing no, but figured I’d ask. Been trying to get this to work for past few days ruling out other issues with my setup.

I get the same error when i try GIT sync. I run 2.9.3 installed in Ubuntu 20.04.4 LTS.

2022-04-07 10:48:02.323 +00:00 [ERR] Failed to sync: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.    at LibGit2Sharp.Core.NativeMethods.git_repository_open_ext(git_repository*& repository, FilePath path, RepositoryOpenFlags flags, FilePath ceilingDirs)
   at LibGit2Sharp.Core.Proxy.git_repository_open_ext(String path, RepositoryOpenFlags flags, String ceilingDirs)
   at LibGit2Sharp.Repository.IsValid(String path)
   at UniversalAutomation.Git.GitService.Exists() in D:\a\universal\universal\src\Universal.Server\Services\GitService.cs:line 75
   at UniversalAutomation.GitSyncService.TrySync() in D:\a\universal\universal\src\Universal.Server\Services\GitSyncService.cs:line 131
   at UniversalAutomation.GitSyncService.Sync() in D:\a\universal\universal\src\Universal.Server\Services\GitSyncService.cs:line 77

This is resolved in 2.10. We just needed to update the libgit2sharp library because they have changed their native dependencies.

1 Like

Currently testing with 2.10.0, working now, thanks.