I have an issue with Carbon 2.2 where it does not correctly update the hosts file. I looked at the release notes of the more recent versions and I did not see anything related to this problem.
I saw the following behaviors:
- The hosts file was emptied
- Only some of the of the new entries were added to the file.
Some background about the issue:
In my Powershell script I add 10 new entries and
Set-HostsEntry would work flawlessly for a few days and then it would start corrupting the hosts file. During this time the same Powershell window was reused.
I traced this issue to the error handling inside the methods for reading and writing the hosts file: they both use
$Global:Error.Count to detect the errors and retry accordingly. In my case, since my Powershell windows was opened for a few days, the
Count was set to 256 and did not increment further which means that the reading or writing was never retried.
The workaround for my script is simply calling
$Error.Clear() at the start of my script but I think this issue should be fixed in an upcoming version of Carbon.