Skip to content

winget upgrade should handle NSIS 'directory not empty' failures (exit code 2) more gracefully #6512

Description

@wukenadela

Brief description of your issue

When winget upgrade runs an NSIS-based installer that refuses to install into a non-empty directory (exit code 2), winget reports the installation as failed with no recovery path. This is a common pattern with conda distributions (Miniforge3, Miniconda, Anaconda) whose NSIS installers reject non-empty target directories.

Related: microsoft/winget-pkgs#431894, conda-forge/miniforge#900

Steps to reproduce

  1. Install Miniforge3 via winget: winget install CondaForge.Miniforge3
  2. Attempt to upgrade: winget upgrade CondaForge.Miniforge3
  3. winget invokes: Miniforge3-26.7.2-0-Windows-x86_64.exe /S /AllUsers /AddToPath=0 /RegisterPython=0
  4. The installer terminates with exit code 2

Current behavior

winget reports:

Installer failed with exit code: 0x8a150003 : Executing command failed

The user is left with no working upgrade path — they must manually uninstall, reinstall, and restore their environments.

Suggested improvement

When an NSIS installer fails with exit code 2 (which often means "directory not empty" or a similar user-correctable condition), winget could:

  1. Detect the specific NSIS exit code (exit code 2 is commonly used for "directory not empty")
  2. Automatically attempt an uninstall-then-reinstall — run the existing installation's uninstaller first, then retry the installer
  3. Or at minimum, provide a more helpful error message suggesting the user try winget uninstall <package> followed by winget install <package>

This would be a general improvement benefiting all NSIS-based packages that exhibit this behavior, not just Miniforge3.

Additional context

The Miniforge3 case is particularly painful because:

  • The envs directory contains user-created conda environments that users want to preserve
  • A simple uninstall+reinstall deletes these environments (see conda-forge/miniforge#448)
  • The miniforge maintainers have marked this as wontfix, so the fix needs to come from the winget side

Environment

  • OS: Windows 11 Pro, build 26200
  • winget: v1.29.290
  • Package: CondaForge.Miniforge3
  • Architecture: x64
  • Scope: machine (all users)

Note: This issue was drafted with AI assistance.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions