This looks like a regression from libgit2 0.28.0, but I'm not sure yet if it's a Rugged issue or a libgit2 one. Here's a sample reproduction:
require 'rugged'
repo = Rugged::Repository.new('.')
start_values = repo.config.each_key.to_a
system('git config --local core.foobar "asdf"')
new_values = repo.config.each_key.to_a
puts "Inserted value: #{repo.config['core.foobar']}"
system('git config --local --unset core.foobar')
puts start_values == new_values
With Rugged 0.27.5, I get:
Inserted value: asdf
false
With Rugged 0.28.0, I get:
Inserted value: asdf
true
What's curious is that the lookup works fine, but the each_key seems to be cached in the 0.28.0 case.
@pks-t @carlosmn I think this has to do with the in-memory config backend in libgit2/libgit2#4767.