Skip to content

Instantly share code, notes, and snippets.

@jessereynolds
Last active February 9, 2017 01:08
Show Gist options
  • Save jessereynolds/6aaae1b6df6e3fa6e1402414455816f3 to your computer and use it in GitHub Desktop.
Save jessereynolds/6aaae1b6df6e3fa6e1402414455816f3 to your computer and use it in GitHub Desktop.
chocolatey nginx uninstallation woes

Uninstalling via puppet seems to not work, but does via choco...

PS C:\puppetcode> puppet resource package nginx-service ensure=absent
package { 'nginx-service':
  ensure => 'absent',
}
PS C:\puppetcode> puppet resource package nginx
package { 'nginx':
  ensure => '1.6.2',
}
PS C:\puppetcode> puppet resource package nginx-service
package { 'nginx-service':
  ensure => '1.6.2.1',
}
PS C:\puppetcode> choco uninstall nginx-service
Chocolatey v0.10.3
Uninstalling the following packages:
nginx-service

nginx-service v1.6.2.1
The package nginx-service wants to run 'chocolateyUninstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider setting
 'allowGlobalConfirmation'. Run 'choco feature -h' for more details.
Do you want to run the script?([Y]es/[N]o/[P]rint): Y

n g i n x :   S T O P :   T h e   o p e r a t i o n   c o m p l e t e d   s u c c e s s f u l l y .



S e r v i c e   " n g i n x "   r e m o v e d   s u c c e s s f u l l y !



 Skipping auto uninstaller - No registry snapshot.
 nginx-service has been successfully uninstalled.

Chocolatey uninstalled 1/1 packages. 0 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
PS C:\puppetcode> puppet resource package nginx-service
package { 'nginx-service':
  ensure => 'absent',
}
PS C:\puppetcode>
PS C:\puppetcode> puppet resource package nginx
package { 'nginx':
  ensure => '1.6.2',
}

Now try removing nginx package, again fails silently from puppet but choco produces a dependency error as it thinks nginx-service is still installed!

PS C:\programdata\nginx> mv conf conf.old
PS C:\programdata\nginx> puppet resource package nginx ensure=absent
package { 'nginx':
  ensure => 'absent',
}
PS C:\programdata\nginx> puppet resource package nginx
package { 'nginx':
  ensure => '1.6.2',
}
PS C:\programdata\nginx> choco uninstall nginx
Chocolatey v0.10.3
Uninstalling the following packages:
nginx
nginx not uninstalled. An error occurred during uninstall:
 Unable to uninstall 'nginx 1.6.2' because 'nginx-service 1.6.2.1' depends on it.

Chocolatey uninstalled 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - nginx (exited 1) - nginx not uninstalled. An error occurred during uninstall:
 Unable to uninstall 'nginx 1.6.2' because 'nginx-service 1.6.2.1' depends on it.

If a package uninstall is failing and/or you've already uninstalled the
 software outside of Chocolatey, you can attempt to run the command
 with `-n` to skip running a chocolateyUninstall script, additionally
 adding `--skip-autouninstaller` to skip an attempt to automatically
 remove system-installed software. This will only remove the packaging
 files and not things like software installed to Programs and Features.

If a package is failing because it is a dependency of another package
 or packages, then you may first need to consider if it needs removed
 as it is typically installed as a dependency for a reason. If you
 decide that you still want to remove it, head into
 `$env:ChocolateyInstall\lib` and find the package folder you want
 removed. Then delete the folder for the package. This option should
 only be used as a last resort.

wondering if my renaming the conf.d dir had a bad effect. Seems to, because if I move it back again, I get:

PS C:\programdata\nginx> mv conf.old conf
PS C:\programdata\nginx> choco uninstall nginx
Chocolatey v0.10.3
Uninstalling the following packages:
nginx
This is try 1/3. Retrying after 300 milliseconds.
Error converted to warning:
Access to the path 'nginx.exe' is denied.
This is try 2/3. Retrying after 400 milliseconds.
Error converted to warning:
Access to the path 'nginx.exe' is denied.
Maximum tries of 3 reached. Throwing error.
Attempted to remove 'C:\ProgramData\chocolatey\lib-bkp\nginx' but had an error::
Access to the path 'nginx.exe' is denied.
This is try 1/3. Retrying after 300 milliseconds.
Error converted to warning:
(183) Cannot create a file when that file already exists: [\\?\C:\ProgramData\chocolatey\lib-bkp\nginx]
This is try 2/3. Retrying after 400 milliseconds.
Error converted to warning:
(183) Cannot create a file when that file already exists: [\\?\C:\ProgramData\chocolatey\lib-bkp\nginx]
Maximum tries of 3 reached. Throwing error.
This is try 1/3. Retrying after 300 milliseconds.
Error converted to warning:
Access to the path 'C:\ProgramData\chocolatey\lib-bkp\nginx\tools\nginx-1.6.2\nginx.exe' is denied.
This is try 2/3. Retrying after 400 milliseconds.
Error converted to warning:
Access to the path 'C:\ProgramData\chocolatey\lib-bkp\nginx\tools\nginx-1.6.2\nginx.exe' is denied.
Maximum tries of 3 reached. Throwing error.
Error during backup (move phase):
Access to the path 'C:\ProgramData\chocolatey\lib-bkp\nginx\tools\nginx-1.6.2\nginx.exe' is denied.
There was an error accessing files. This could mean there is a
process locking the folder or files. Please make sure nothing is
running that would lock the files or folders in this directory prior
to upgrade. If the package fails to upgrade, this is likely the cause.
nginx not uninstalled. An error occurred during uninstall:
Unable to uninstall 'nginx 1.6.2' because 'nginx-service 1.6.2.1' depends on it.

Chocolatey uninstalled 0/1 packages. 1 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
- nginx (exited 1) - nginx not uninstalled. An error occurred during uninstall:
Unable to uninstall 'nginx 1.6.2' because 'nginx-service 1.6.2.1' depends on it.

If a package uninstall is failing and/or you've already uninstalled the
software outside of Chocolatey, you can attempt to run the command
with `-n` to skip running a chocolateyUninstall script, additionally
adding `--skip-autouninstaller` to skip an attempt to automatically
remove system-installed software. This will only remove the packaging
files and not things like software installed to Programs and Features.

If a package is failing because it is a dependency of another package
or packages, then you may first need to consider if it needs removed
as it is typically installed as a dependency for a reason. If you
decide that you still want to remove it, head into
`$env:ChocolateyInstall\lib` and find the package folder you want
removed. Then delete the folder for the package. This option should
only be used as a last resort.

PS C:\programdata\nginx>

Seems there is a permissions issue that is preventing package uninstallation.

@jessereynolds
Copy link
Author

there is something wrong with this picture. puppet resource service run on this windows 2012r2 host, note the nginx service status.

screenshot 2017-02-09 09 04 37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment