'LibGit2Sharp.NotFoundException: the ProgramData file 'config' doesn't exist' when pushing on MacOS
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 30/100
- Issue-Typ
- Bug
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- csharp, git, macos
- Bereich
- developer-experience
Rechercherichtung
Den Push unter macOS 15.4.1 mit dem gezeigten Configuration.BuildFrom- und Push-Code reproduzieren. Beginne mit Configuration.cs:75 und verfolge anschließend Repository.cs:220, Branch.cs:181 und Network.cs:327, um zu ermitteln, warum die ProgramData-Konfiguration erforderlich ist. Als abgeschlossen gilt die Aufgabe, wenn das Repository ohne die Ausnahme wegen der fehlenden Konfiguration pushen kann und eine Abdeckung für den gemeldeten Konfigurationspfad vorhanden ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Hello,
I am facing this issue on MacOS 15.4.1 Sequoia, Apple M2.
I am trying to push some changes I made, to the remote location but I get the following exception thrown when pushing (cloning and committing the changes obviously worked fine).
There is a .gitconfig in my user home directory with the according user.name & user.email section key value pairs.
Additionally I update the local /.git/config file with these information and manually checked that the file is actually updated.
Is this a bug? And if so, is it related to https://github.com/libgit2/libgit2sharp/issues/2046?
But the more pressing question is, how can I workaround this issue?
Here is the stack trace, saying the config file cannot be found in the program data (which obviously is a windows related naming):
LibGit2Sharp.NotFoundException: the ProgramData file 'config' doesn't exist:
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 172
at LibGit2Sharp.Core.Proxy.git_config_add_file_ondisk(ConfigurationHandle config, FilePath path, ConfigurationLevel level, RepositoryHandle repo) in /_/LibGit2Sharp/Core/Proxy.cs:line 449
at LibGit2Sharp.Configuration.Init(Repository repository) in /_/LibGit2Sharp/Configuration.cs:line 75
at LibGit2Sharp.Configuration..ctor(Repository repository, String repositoryConfigurationFileLocation, String globalConfigurationFileLocation, String xdgConfigurationFileLocation, String systemConfigurationFileLocation) in /_/LibGit2Sharp/Configuration.cs:line 49
at LibGit2Sharp.Repository.<>c__DisplayClass25_1.<.ctor>b__3() in /_/LibGit2Sharp/Repository.cs:line 220
at System.Lazy`1[[LibGit2Sharp.Configuration, LibGit2Sharp, Version=0.31.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333]].ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1[[LibGit2Sharp.Configuration, LibGit2Sharp, Version=0.31.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333]].ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1[[LibGit2Sharp.Configuration, LibGit2Sharp, Version=0.31.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333]].CreateValue()
at System.Lazy`1[[LibGit2Sharp.Configuration, LibGit2Sharp, Version=0.31.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333]].get_Value()
at LibGit2Sharp.Repository.get_Config() in /_/LibGit2Sharp/Repository.cs:line 323
at LibGit2Sharp.Branch.UpstreamBranchCanonicalNameFromLocalBranch() in /_/LibGit2Sharp/Branch.cs:line 181
at LibGit2Sharp.Branch.get_UpstreamBranchCanonicalName() in /_/LibGit2Sharp/Branch.cs:line 155
at LibGit2Sharp.Network.Push(IEnumerable`1 branches, PushOptions pushOptions) in /_/LibGit2Sharp/Network.cs:line 327
at LibGit2Sharp.Network.Push(Branch branch, PushOptions pushOptions) in /_/LibGit2Sharp/Network.cs:line 299
at versioning.MainPageViewModel.CommitAndPushVersionChanges(String repository, String branch, String jiraIssue, String username, String token, String version)
Here is my code to update the local config file:
private static Configuration BuildConfuration(string repositoryLocation, string username, string email) Configuration.BuildFrom(repositoryLocation + "/.git/config", userHomeFolder() + "/.gitconfig");
configuration.Add("user.name", username);
configuration.Add("user.email", email, ConfigurationLevel.Local);
Here is the code that produces the exception:
private static void CommitAndPushVersionChanges(string repository, string branch, string email, string username, string token)
{
using var repo = new Repository(repository);
// Stage the file
repo.Index.Add("a.txt");
repo.Index.Write();
var configuration = BuildConfiguration(repository, username, email);
var author = configuration.BuildSignature(DateTimeOffset.Now);
// Commit & Push to the repository
repo.Commit($"Commit Message", author, author);
var options = new PushOptions
{
CredentialsProvider = (_, _, _) =>
new UsernamePasswordCredentials
{
Username = "x-token-auth",
Password = token
}
};
// EXCEPTION IS THROWN FOR THIS CALL
repo.Network.Push(repo.Branches[branch], options);
}
Can anybody help?
Cheers
Samir
- Vorherrschende Sprache
- C#
- Sterne
- 3.5k
- Forks
- 925
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus libgit2/libgit2sharp
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
libgit2/libgit2sharp#2193 · 2 Kommentare ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 38/100
libgit2/libgit2sharp#2192 · 1 Kommentar ·
-
Website is down Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 20/100
libgit2/libgit2sharp#2191 · 2 Reaktionen ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
libgit2/libgit2sharp#2189 · 1 Reaktion ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
libgit2/libgit2sharp#2187 · 2 Kommentare ·
Alle Issues in libgit2/libgit2sharp
Ähnliche Issues
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
azurenoops/spin_agent#975 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
SubtitleEdit/subtitleedit#15108 · 1 Kommentar ·