Search code examples
powershellpowershell-7

PSCommandNotFoundSuggestion message shows without suggestions (PowerShell 7.5)


I recently upgraded to PowerShell 7.5, where PSCommandNotFoundSuggestion has become a mainstream feature.

Often, after running a successful command I see the message...

Suggestion [4,General]: The most similar commands are:

... followed by no suggestions.

I wouldn't expect this message to display given that a) the original command was found, and b) no suggestions were found.

My question is: How can I fix this behaviour, or disable this feature?

I believe in PowerShell 7.4 you could use Disable-ExperimentalFeature PSCommandNotFoundSuggestion (see here). However, since PSCommandNotFoundSuggestion is now a mainstream feature this method doesn't seem to work any more.


Solution

  • You're seeing a bug, which the powers that be - unfortunately - decided not to fix:

    • See GitHub issue #20916; the decision there mentions that the issue may be revisited if there's community interest, however.

    • In a nutshell, the PSCommandNotFoundSuggestion feature was made stable in v7.5.0, even though it depends on another feature that is still experimental, namely the PSFeedbackProvider feature.

      • In stable / LTS PowerShell versions (as opposed to preview versions, experimental features are disabled by default, so the missing dependency causes the PSCommandNotFoundSuggestion feature to malfunction.

      • PSFeedbackProvider will become a stable feature in v7.6.0 at the earliest.

    For now (except by default in 7.6 preview versions), avoiding the bug requires explicitly enabling the PSFeedbackProvider experimental feature as follows:

    # Start a new session afterwards for the change to take effect.
    Enable-ExperimentalFeature PSFeedbackProvider
    

    Note that there is no way to disable the PSCommandNotFoundSuggestion feature that I'm aware of.