Skip to content
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

Auto Uninstaller can fail if chocolateyUninstall.ps1 uninstalls prior to it running #304

Closed
mrdima opened this issue Jun 4, 2015 · 8 comments
Assignees
Milestone

Comments

@mrdima
Copy link

mrdima commented Jun 4, 2015

When chocolateyUninstall.ps1 does an uninstall / cleanup or whatever it needs to do, the autouninstaller kicks in too soon it seems...

For inno setup installers, de uninst000.exe is deleted eventually by the chocolateyUninstall.ps1 kicking off the uninstall, but when the autouninstall is triggered it's still there, but the unins000.dat has already been removed. It's probably something with the windows installer service still finalizing things.
Doing a Start-Sleep -Seconds 10 at the end in the chocolateyUninstall.ps1 can be done as a workaround as the Windows Installer Service has probably finished cleaning up everything which the autouninstall will then notice.

For MSI's we got something similar...the key is still there but already removed when msiexec kicked off from the uninstaller is going to do its thing (but I'm not sure)

VERBOSE: Exporting alias 'Add-BinFile'.
VERBOSE: Exporting alias 'Remove-BinFile'.
Command ['"MsiExec.exe" /X{BA7FB0F2-4B28-444F-8199-CF8402DA342E} /qn /norestart'
] exited with '1605'
Auto uninstaller failed. Please remove machine installation manually.
centerityagent-plugins uninstall not successful.
Auto uninstaller failed. Please remove machine installation manually.
[NuGet] Removed file 'chocolateyinstall.ps1' to folder 'C:\Chocolatey\lib\Whatever\tools'.
[NuGet] Removed file 'chocolateyuninstall.ps1' to folder 'C:\Chocolatey\lib\Whatever\tools'.
[NuGet] Removed folder 'C:

@ferventcoder
Copy link
Member

1605 is being added as a valid uninstall exit code, since it means the product is not installed

@ferventcoder
Copy link
Member

Adding that for #305.

@ferventcoder
Copy link
Member

Why 10 seconds?

@mrdima
Copy link
Author

mrdima commented Jun 4, 2015

No reason, it was arbitrary and proven to be long enough on 1 system I tested, but might not be enough for others. I really hope there's some better way to detect whether the uninstall is truely finished cleaning up...I noticed chocolatey returning on the msi uninstall but the directory was still there for a few seconds (doing just dir c:\install dir after cuninst)...

@ferventcoder
Copy link
Member

That's fair.

@ferventcoder ferventcoder self-assigned this Jun 4, 2015
@ferventcoder ferventcoder added this to the 0.9.9.7 milestone Jun 4, 2015
ferventcoder added a commit that referenced this issue Jun 4, 2015
If the preceeding chocolatelyUninstall.ps1 uninstalls an application,
sometimes the system is still cleaning up files and registry keys.
Those keys are found by the auto installer and it decides to also move
forward with the uninstall. In cases like that, the auto uninstaller
should wait a few seconds before moving forward with checks.
@ferventcoder
Copy link
Member

This is completed with b82436b

@ferventcoder ferventcoder changed the title autouninstaller can fail when there's also a chocolateyUninstall.ps1 Auto Uninstaller can fail if chocolateyUninstall.ps1 uninstalls prior to it running Jun 4, 2015
ferventcoder added a commit that referenced this issue Jun 4, 2015
* stable:
  (GH-296) add 1605 for valid MSI exit code
  (GH-305) Installer Type Validate Exit Code
  (GH-305) Find the installer type every time
  (maint) formatting
  (GH-304) Auto Installer allow system cleanup
  (GH-305) Clean up installer types
@mrdima
Copy link
Author

mrdima commented Jun 5, 2015

I'm sorry to say that after re-investigating the reason for the auto-uninstaller to fail is indeed caused by the uninstallers still running which was triggered from chocolateyUninstall.ps1, but this shouldn't normally happen. It happened because I used Invoke-Expression to run the uninstaller which apperently doesn't wait for the proces to exit (at least not for inno setup or msiexec processes). If I modify that (in this case in less pretty Invoke-Expression cmd.exe /c start /w dotheuninstallthing, but could use other Powershell commands to start the proces which includes waits) everything works fine. So the workaround with a sleep timeout wasn't necessary though maybe there's cases where this is convenient to have) but you can reconsider this patch. Great work in #305!

@ferventcoder
Copy link
Member

Posh v3 has issues with wait - we have bits built in to make the process wait - as long as you are using start-chocolateyprocessasadmin it should block.

ferventcoder added a commit to ferventcoder/choco that referenced this issue Jun 5, 2015
When waiting for the system to finish cleaning up, 2 seconds seems more
appropriate.
ferventcoder added a commit to ferventcoder/choco that referenced this issue Jun 5, 2015
* stable:
  (chocolateyGH-315) Nuget stops when uninstall fails
  (chocolateyGH-316) Prevent reboots
  (chocolateyGH-305) Do not fail by default on auto uninstaller
  (chocolateyGH-304) Reduce sleep time to 2 seconds
  (chocolateyGH-305) Include exit code when there is an error
  (chocolateyGH-305) Log info instead of Debug
  (chocolateyGH-305) Don't attempt to log on uninstall

Conflicts:
	src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs
	src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants