{"record":{"id":"11837b6f40977002","repo":"git-ecosystem/git-credential-manager","slug":"unable-to-persist-credentials-with-the-storename","errorCode":null,"errorMessage":"Unable to persist credentials with the '{StoreNames.WindowsCredentialManager}' credential store.\nSee {Constants.HelpUrls.GcmCredentialStores} for more information.","messagePattern":"Unable to persist credentials with the '(.+?)' credential store\\.\nSee (.+?) for more information\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Core/CredentialStore.cs","lineNumber":212,"sourceCode":"                Environment.NewLine, StoreNames.None);\n        }\n\n        private void ValidateWindowsCredentialManager()\n        {\n            if (!PlatformUtils.IsWindows())\n            {\n                var message = $\"Can only use the '{StoreNames.WindowsCredentialManager}' credential store on Windows.\";\n                _context.Trace2.WriteError(message);\n                throw new Exception(message + Environment.NewLine +\n                            $\"See {Constants.HelpUrls.GcmCredentialStores} for more information.\"\n                );\n            }\n\n            if (!WindowsCredentialManager.CanPersist())\n            {\n                var message = $\"Unable to persist credentials with the '{StoreNames.WindowsCredentialManager}' credential store.\";\n                _context.Trace2.WriteError(message);\n                throw new Exception(message + Environment.NewLine +\n                    $\"See {Constants.HelpUrls.GcmCredentialStores} for more information.\"\n                );\n            }\n        }\n\n        private void ValidateDpapi(out string storeRoot)\n        {\n            if (!PlatformUtils.IsWindows())\n            {\n                var message = $\"Can only use the '{StoreNames.Dpapi}' credential store on Windows.\";\n                _context.Trace2.WriteError(message);\n                throw new Exception(message  + Environment.NewLine +\n                    $\"See {Constants.HelpUrls.GcmCredentialStores} for more information.\"\n                );\n            }\n\n            // Check for a redirected credential store location\n            if (!_context.Settings.TryGetSetting(","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/CredentialStore.cs#L194-L230","documentation":"ValidateWindowsCredentialManager also checks WindowsCredentialManager.CanPersist() on Windows itself. If Credential Manager cannot persist credentials (e.g. no writable credential vault, restricted service, or a stripped-down environment), GCM throws this error indicating the wincredman store is unusable on this machine.","triggerScenarios":"EnsureBackingStore -> ValidateWindowsCredentialManager where PlatformUtils.IsWindows() is true but WindowsCredentialManager.CanPersist() returns false — the Credential Manager API cannot write/persist entries in the current environment.","commonSituations":"Running inside restricted Windows service accounts or sandboxed CI runners with the Credential Manager service disabled; locked-down enterprise policies; minimal Windows containers lacking the Credential Manager runtime.","solutions":["Switch to another store: `git config --global credential.credentialStore dpapi` (with a store root) or plaintext/cache for non-interactive contexts.","Ensure the Credential Manager (VaultSvc / 'Credential Manager') service is running and not disabled by policy.","Run GCM under an interactive user account with a writable user profile instead of a service/CI identity.","Check enterprise/group policy restrictions and ask IT to allow credential persistence."],"exampleFix":"// before (CI container without Credential Manager)\n[credential]\n\tcredentialStore = wincredman\n\n// after\n[credential]\n\tcredentialStore = dpapi","handlingStrategy":"fallback","validationCode":"// Windows-only preflight\nif (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && store == \"wincredman\")\n{\n    using var ps = System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(\"sc.exe\", \"query VaultSvc\") { RedirectStandardOutput = true, UseShellExecute = false });\n    string output = ps.StandardOutput.ReadToEnd(); ps.WaitForExit();\n    if (!output.Contains(\"RUNNING\")) throw new InvalidOperationException(\"Credential Manager service unavailable; use dpapi or plaintext\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    credentialStore.Get(serviceName);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"Unable to persist credentials\"))\n{\n    // fall back to a non-Credential-Manager store (dpapi/cache/plaintext)\n}","preventionTips":["Verify the Credential Manager (VaultSvc) service is running on Windows hosts.","Prefer dpapi/cache in service accounts, CI runners and containers.","Avoid wincredman in minimal Windows images.","Check enterprise policy before standardizing on Credential Manager."],"tags":["git","credential-store","windows","environment"],"backgroundTag":"unsupported-operation","analyzedSha":"e8ce762cd04b4100ae637b5fbf39ef9d0a96561e","analyzedAt":"2026-09-11T17:15:08.753Z","contentChangedAt":"2026-09-11T17:15:08.753Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}