Skip to content

Conversation

@meaksh
Copy link
Contributor

@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.

What issues does this PR fix or reference?

Fixes #64121

Merge requirements satisfied?

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

Commits signed with GPG?

Yes

This prevents the generic error:

_pygit2.GitError: error loading known_hosts:

which is happening in certain pygit2/libgit2 versions
twangboy
twangboy previously approved these changes Oct 3, 2025
Copy link
Contributor

@dwoz dwoz left a comment

Choose a reason for hiding this comment

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

Otherwise his can be merged.

@dwoz dwoz merged commit 07bbb95 into saltstack:3006.x Oct 28, 2025
1999 of 2008 checks passed
@meaksh meaksh deleted the 3006.x-fix-known_hosts-error-pygit2 branch October 28, 2025 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] onedir blocks installation of shared libraries for pygit2 gitfs in 3006.0

3 participants