-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chocolatey config changes in 0.10.4+ - The process cannot access the file because it is being used by another process #1241
Comments
If you run into this error, please provide the output of the following:
|
configs at the time of issue, if helps |
Thanks! This will help |
Our site is affected by this problem. Thanks for working on this. You can downgrade chocolatey with this command: Close the powershell window and then run puppet again: |
This is very odd. File locks were something I was trying hard to avoid :| |
This change also affects DSC:
|
I believe this is fixed for 0.10.6. |
When writing a file with streams, use the built in methods in IFileSystem for doing so.
Using File.Replace can have some access violation concerns. It demands full access to a file, which can cause issues if the file is locked. If a file is open in another process, it has issues renaming the file, which causes the rest to not work appropriately. Implement file replace methods in a move step that will work with files that are open and then copy the original file to the destination and delete the original file. If the file locked is the backup file, it should log that it was not able to produce the backup and continue without failure. If it has issues removing the source file, it should log that it was not able to delete the file and continue without failure.
To really limit the possibility of something holding a lock on a file, use process id in files. Also attempt to clean up any locked update files when getting the configuration.
For resources that need closed and disposed in XmlService, explicitly handle closing of those resources. This allows being extremely explicit about when resources are cleaned up and subsequently released.
When moving a file to a new location, create the directory for the new file if it doesn't already exist.
Log tracing output surrounding working with xml files.
* pr1264: (26 commits) (maint) COMMITTERS - EOL change to CRLF (doc) update CONTRIBUTING/COMMITTERS (GH-1241) XmlService - trace logging information (maint) formatting (GH-1241) FileSystem - move file creates directory (GH-1241) Explicitly handle closing (maint) formatting (GH-1292) Ensure manifest extracted on unpackself (log) replace_file use new lines for log (maint) update CHANGELOG / nuspec (maint) nuspec - add info links to description (maint) clean up lib nuspec (GH-1311) Install-ChocolateyPowershellCommand File/FileFullPath aliases (GH-1284) ensure file/filefullpath on functions (maint) ReadMe updates (GH-1241) Use process id with update file (maint) restrict list start/end messages to log file (GH-1309) Restrict trace output (GH-1241) More Robust File.Replace (GH-1241) Use write_file for stream writing ...
* stable: (26 commits) (maint) COMMITTERS - EOL change to CRLF (doc) update CONTRIBUTING/COMMITTERS (GH-1241) XmlService - trace logging information (maint) formatting (GH-1241) FileSystem - move file creates directory (GH-1241) Explicitly handle closing (maint) formatting (GH-1292) Ensure manifest extracted on unpackself (log) replace_file use new lines for log (maint) update CHANGELOG / nuspec (maint) nuspec - add info links to description (maint) clean up lib nuspec (GH-1311) Install-ChocolateyPowershellCommand File/FileFullPath aliases (GH-1284) ensure file/filefullpath on functions (maint) ReadMe updates (GH-1241) Use process id with update file (maint) restrict list start/end messages to log file (GH-1309) Restrict trace output (GH-1241) More Robust File.Replace (GH-1241) Use write_file for stream writing ... # Conflicts: # CONTRIBUTING.md # README.md
Okay, now this is ready for 0.10.6. |
The fixes completed for #1047 are now causing the following error when using Puppet's Chocolatey provider to set configuration:
The process cannot access the file because it is being used by another process
This is likely due to the Puppet provider holding a lock on the original file. The original method renamed that file and wrote a new file in it's place, which allowed issues with something holding a lock on a file and so it was never caught in testing - https://github.com/puppetlabs/puppetlabs-chocolatey/blob/5e3af2410863a216a4cb0dce90a74171f9873931/lib/puppet/provider/chocolateysource/windows.rb#L45-L48
https://tickets.puppetlabs.com/browse/MODULES-4678 is the issue for the Puppet provider.
This has been validated by folks using Puppet and outside of Puppet when they run Chocolatey. It's like something now has an lock on the file, except for the folks that have checked, there is nothing holding a lock on the file itself. Seems to be a race condition somewhere.cc @RichiCoder1
More details
This appears to happen after:
Workaround
Downgrade to Chocolatey v0.10.3 until this is resolved.
The text was updated successfully, but these errors were encountered: