git-ecosystem/git-credential-manager · error · Trace2Exception

Failed to enumerate all Git configuration entries

Error message

Failed to enumerate all Git configuration entries

What it means

Thrown by GitConfiguration.Enumerate when `git config --list` (at a given level) exits non-zero. This error means the requested configuration could not be read at all — typically a malformed config file or an inaccessible config location — so the library cannot return any entries.

Solutions

  1. Run `git config --list` manually to find the parse error message and offending file
  2. Fix the malformed line in the indicated config file (git prints file:line)
  3. Back up and regenerate the broken config file if it is beyond repair
  4. Check HOME/XDG_CONFIG_HOME and file permissions for the global/system config

Example fix

// before
var entries = config.Enumerate(GitConfigurationLevel.Local); // throws on malformed file
// after
List<string> entries;
try { entries = config.Enumerate(GitConfigurationLevel.Local).ToList(); }
catch (GitException ex) { entries = new List<string>(); Log(ex.Message); }
Defensive patterns

Strategy: try-catch

Validate before calling

var probe = Process.Run("git", "config --list", workingDir);
if (probe.ExitCode != 0) { /* fix config before calling Enumerate */ }

Type guard

bool CanReadConfig(GitConfiguration cfg) { try { _ = cfg.Enumerate(GitConfigurationLevel.Local).Any(); return true; } catch (GitException) { return false; } }

Try / catch

try { entries = cfg.Enumerate(level).ToList(); }
catch (GitException ex) { log.Error($"Config unreadable: {ex.Message}"); entries = new List<string>(); }

Prevention

When it happens

Trigger: Calling Enumerate(level) when the underlying `git config --list --<level>` process fails: malformed .gitconfig syntax, unreadable system/global config file, or invalid level combination.

Common situations: Hand-edited .gitconfig with syntax errors; XDG_CONFIG_HOME or HOME pointing somewhere unreadable; corporate config templates with duplicate/conflicting entries.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11). Data as JSON: /api/errors/32634aaf660a1dcd. Report an issue: GitHub.

Appendix: source

Thrown at src/Core/GitConfiguration.cs:480

            }

            // Fall back to original implementation
            string levelArg = GetLevelFilterArg(level);
            using (ChildProcess git = _git.CreateProcess($"config --null {levelArg} --list"))
            {
                git.Start(Trace2ProcessClass.Git);
                // To avoid deadlocks, always read the output stream first and then wait
                // TODO: don't read in all the data at once; stream it
                string data = git.StandardOutput.ReadToEnd();
                git.WaitForExit();

                switch (git.ExitCode)
                {
                    case 0: // OK
                        break;
                    default:
                        _trace.WriteLine($"Failed to enumerate config entries (exit={git.ExitCode}, level={level})");
                        throw GitProcess.CreateGitException(git, "Failed to enumerate all Git configuration entries");
                }

                var name  = new StringBuilder();
                var value = new StringBuilder();
                int i = 0;
                while (i < data.Length)
                {
                    name.Clear();
                    value.Clear();

                    // Read key name (LF terminated)
                    while (i < data.Length && data[i] != '\n')
                    {
                        name.Append(data[i++]);
                    }

                    if (i >= data.Length)
                    {

View on GitHub (pinned to e8ce762cd0)