Skip to content

Conversation

@meaksh
Copy link
Member

@meaksh meaksh commented Oct 3, 2025

What does this PR do?

This PR fixes the generic error that is still seen around gitfs with certain pygit2 and libgit2 versions:

_pygit2.GitError: error loading known_hosts:

After debugging libgit2 and pygit2 I was able to understand what's going on here. The internal git_sysdir__dirs struct is populated during libgit2 initialization, which is only triggered at the time of importing pygit2 module.

If the HOME environment variable is not defined when importing pygit2, then the internal guess function from libgit2 to determine the homedir (git_sysdir_guess_home_dirs) fails to define the HOME path for the initializated stack. Therefore the above error occurs.

Also once pygit2/libgit2 is instantiated, there is no way until pygit2 version 1.18.2 to explicitely redefine the internal home dir on the initializated stack, as GIT_OPT_SET_HOMEDIR wasn't implemented in pygit2 until 1.18.2. See libgit2/pygit2#1409

So, this PR makes sure the HOME env variable is present at the time of importing pygit2 at salt.utils.gitfs.

Upstream PR: saltstack/salt#68366

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

meaksh added 2 commits October 3, 2025 12:22
This prevents the generic error:

_pygit2.GitError: error loading known_hosts:

which is happening in certain pygit2/libgit2 versions
@meaksh meaksh force-pushed the openSUSE/fix/3006.0-fix-pygit2-known_hosts-issue branch from 13932c7 to b68ea0a Compare October 3, 2025 12:05
@meaksh meaksh changed the title Allow libgit2 to guess sysdir homedir successfully (bsc#1250520) Allow libgit2 to guess sysdir homedir successfully (bsc#1250520) (bsc#1227207) Oct 3, 2025
Copy link
Contributor

@vzhestkov vzhestkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@meaksh meaksh merged commit 6a57e82 into openSUSE/release/3006.0 Oct 6, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants