question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Interacting with configuration where not ProgramData config does not exists now throws an exception

See original GitHub issue

It’s not immediately clear what side the bug is on, but the latest upgrade to libgit2 v1.6.2 seems to have introduced an issue with the loading of the ProgramData config path in lib2git.

Reproduction steps

  1. Ensure you have no configuration file in the program data directory. In the LibGit2Sharp tests these are generated automatically in %userprofile%\AppData\Local\Temp\LibGit2Sharp-TestRepos which may explain why it wasnt picked up in the tests

  2. Try to read any config

var repo = new Repository();
repo.Config.Get<bool>("core.autocrlf");

Expected behavior

The Configuration.cs constructor should load what configuration it can and continue on its way. libgit2 should presumably be returning a 0 as some of the other missing config paths do, which would result in the path resolving “successfully” to null

Actual behavior

The call down to NativeMethods.git_config_find_programdata returns a -1 with an error message that resolves as

LibGit2Sharp.LibGit2SharpException: the ProgramData file 'config' doesn't exist: 
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in D:\Development\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 154
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in D:\Development\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 172
   at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) in D:\Development\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 3801
   at LibGit2Sharp.Core.Proxy.git_config_find_programdata() in D:\Development\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 497
   at LibGit2Sharp.Configuration..ctor(Repository repository, String repositoryConfigurationFileLocation, String globalConfigurationFileLocation, String xdgConfigurationFileLocation, String systemConfigurationFileLocation) in D:\Development\libgit2sharp\LibGit2Sharp\Configuration.cs:line 47
   at LibGit2Sharp.Repository.<>c__DisplayClass25_1.<.ctor>b__3() in D:\Development\libgit2sharp\LibGit2Sharp\Repository.cs:line 220
   at System.Lazy`1.CreateValue()

Testing against the previous version it looks like this was previously not an enforced configuration file.

Version of LibGit2Sharp (release number or SHA1)

master (commit 70d62d5)

Operating system(s) tested; .NET runtime tested

Windows 11

Issue Analytics

  • State:closed
  • Created 6 months ago
  • Reactions:2
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bordingcommented, Apr 13, 2023

@zentron LibGit2Sharp 0.27.2 is out and includes the change, so you can try it now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Latest Update brings Github error on pull, push, or sync
You should check if 'C:\ProgramData/Git/config' actually exists. If it doesn't you can just create it and paste the following into the file:
Read more >
Veeam Backup & Replication Console Fails to Open
I navigated all the way down to F:\ProgramData\Veeam\Backup\IRCache\NfsDatastore but no files existed. (I checked to ensure that the directories ...
Read more >
After installing, elasticsearch will not start due to no logging ...
Caused by: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config. Be a key? That directory or file does not exist on my node.
Read more >
Understanding and troubleshooting WinRM connection and ...
The Winrm service is not running on the remote machine; The firewall on the remote machine is refusing connections; A proxy server stands...
Read more >
Throw warning on invalid config · Issue #250 · laravel/ideas
Currently if you call a config value that is does not exist/invalid - it is a silent failure: dd(config('custom.i_do_not_exist')) // null.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found