Closed mwallner closed 7 years ago
The error seems to be in chocolatey/infrastructure/services/XmlService.cs
I can reproduce the _fileSystem.copy_file
to be ?unsuccessful? (only a certain amount of data is replaced within chocolatey.config) - afterwards xmlUpdateFilePath gets deleted.
Maybe a timing issue? (xmlUpdateFilePath should only be deleted after _fileSystem.copy_file has finished..)
@mwallner note that this writes a file called chocolatey.config.update, then it compares this file versus the original to see if it has changed (line 86 in your image). Only then does it copy over the existing.
I think possibly we need to read the file back in to see if it is valid prior to overwriting. What do you think?
@ferventcoder as far as I've tracked the bug it seems to be a timing issue .. I think the file isn't really written synchronously with _fileSystem.copy_file - and _fileSytem.delete_file stops the copy-operation somewhere during it's runtime..
I'd suggest to only delete the .update file if the content of the .config file and the .update file match
Fixed for 0.10.4
Please reopen, still an Issue in 0.10.5
here's a sample of chocolatey.config
after two processes accessed it simultaneously:
<?xml version="1.0" encoding="utf-8"?>
<chocolatey xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<containsLegacyPackageInstalls>false</containsLegacyPackageInstalls>
<commandExecutionTimeoutSeconds>0</commandExecutionTimeoutSeconds>
<config>
<add key="cacheLocation" value="" description="Cache location if not TEMP folder." />
<add key="containsLegacyPackageInstalls" value="true" description="Install has packages installed prior to 0.9.9 series." />
<add key="commandExecutionTimeoutSeconds" value="2700" description="Default timeout for command execution." />
<add key="
1 good thing though: now there's a .config.backup
and config.update
file as well - still containing the correct configuration.
Isnt it re-referenced here?
https://github.com/chocolatey/choco/issues/1241
oh nope nevermind. this ticket is linked to that, but closed. I do still have this issue in 10.5 as well. We just moved all our hosts back to 10.3 for the time being.
The fixes that went into for this are supposed to look at the file after it saves it and determine if it is good - if not it should roll back old config.
Let's open a new issue and reference this one.
First of all, I do know this problem seems to be related to ChocolateyGUI (read on) - but I think the error is in chocolatey.dll - so I decided to post this Issue here.
chocolatey.config xml gets corrupted
When starting chocolateyGUI while another process uses choco (like choco.exe from command-line) - chocolatey.config will be corrupted and can't be read any longer. - invalid xml, the XML serializer just seems to stop writing the file.
example of .config before the issue occurs
example of .config afterwards
once this occurs, chocolatey can't be used anymore:
the output
choco list -lo -verbose -debug
:chocolatey.config should only be read, not written every time ChocolateySources are read via chocolatey.dll
Why does chocolatey.config need to be written every time ChocolateyGUI is opened?
steps to reproduce
C:\ProgramData\chocolatey\config\chocolatey.config
will be corruptedscreenshots
Having a look at the soures of chocolateyGUI reveals that this happens during initialization of
chocolatey.dll