chocolatey/choco · error · FileNotFoundException

Unable to find suitable location for the executable. Searche

Error message

Unable to find suitable location for the executable. Searched the following locations: '{0}'

What it means

WindowsFeatureService.EnsureExecutablePathSet iterates a list of candidate executable locations (_exeLocations). If none exists on disk, _exePath stays blank and it throws FileNotFoundException listing every searched path joined by '; '.

Source

Thrown at src/chocolatey/infrastructure.app/services/WindowsFeatureService.cs:187

        private void EnsureExecutablePathSet()
        {
            if (!string.IsNullOrWhiteSpace(_exePath))
            {
                return;
            }

            foreach (var location in _exeLocations)
            {
                if (_fileSystem.FileExists(location))
                {
                    _exePath = location;
                    break;
                }
            }

            if (string.IsNullOrWhiteSpace(_exePath))
            {
                throw new FileNotFoundException("Unable to find suitable location for the executable. Searched the following locations: '{0}'".FormatWith(string.Join("; ", _exeLocations)));
            }
        }

        public void ListDryRun(ChocolateyConfiguration config)
        {
            EnsureExecutablePathSet();
            var args = BuildArguments(config, _listArguments);
            this.Log().Info("Would have run '{0} {1}'".FormatWith(_exePath.EscapeCurlyBraces(), args.EscapeCurlyBraces()));
        }

        public IEnumerable<PackageResult> List(ChocolateyConfiguration config)
        {
            EnsureExecutablePathSet();
            var args = BuildArguments(config, _listArguments);
            var packageResults = new List<PackageResult>();

            Environment.ExitCode = _commandExecutor.Execute(
                _exePath,

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Run on a supported Windows edition that includes the servicing tooling (DISM)
  2. Repair the Windows component store (DISM /Online /Cleanup-Image /RestoreHealth)
  3. Verify the expected executable paths in _exeLocations actually exist
  4. Use the alternative WindowsFeatures backend (e.g. the Get-WindowsOptionalFeatures PowerShell source) if available

Example fix

// before
# DISM missing -> error
// after
DISM /Online /Cleanup-Image /RestoreHealth
choco list --source=windowsfeatures
Defensive patterns

Strategy: validation

Validate before calling

var found = _exeLocations.Any(p => fileSystem.FileExists(p));
if (!found) {
    throw new FileNotFoundException($"Windows features executable not found in: {string.Join("; ", _exeLocations)}");
}

Try / catch

try { windowsFeatureService.List(config); }
catch (FileNotFoundException ex) when (ex.Message.Contains("suitable location for the executable")) {
    // repair component store (DISM /Online /Cleanup-Image /RestoreHealth) then retry
    logger.Error(ex.Message);
}

Prevention

When it happens

Trigger: Initializing the Windows Features source when the underlying servicing executable (e.g. DISM) is not found at any configured _exeLocations path, so FileExists is false for all and _exePath remains empty.

Common situations: A stripped Windows edition/core SKU without the servicing tooling; a corrupted Windows component store; custom Windows images where the expected exe paths are missing or relocated.

Related errors


AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13). Data as JSON: /api/errors/32fe4f0d46153d0d. Report an issue: GitHub.