question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide relevant suggestions when dotnet command is not found

See original GitHub issue

If I make a typo in my dotnet command, it tells me this:

C:\git\performance>dotnet buildserver
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program, but dotnet-buildserver does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

But dotnet knows that there is a very similar valid option, “build-server”.

git, however, is more useful:

C:\git\performance>git cherrypick abc123
git: 'cherrypick' is not a git command. See 'git --help'.

The most similar command is
        cherry-pick

Benchmark.NET does this also, eg

[2022/02/07 18:13:46][INFO] You must have made a typo in '*ByteMark.BenchFurier*'. Suggestions:
[2022/02/07 18:13:46][INFO]     ByteMark.BenchFourier
[2022/02/07 18:13:46][INFO] To print all available benchmarks use `--list flat` or `--list tree`.

They both do this by the well established procedure of selecting the alternatives that have the lowest Levenshtein distance from the invalid input. This can be done whenever the valid inputs are known strings. The typo does not need to be a missing or extra character, it can be a transposition or substitution - Levenshtein distance just ranks by the smallest number of insertions, deletions, or edits between the valid and the invalid strings. Typically, this handles everyday typos effectively.

Benchmark.NET has the MIT license and with attribution dotnet can reuse its code from here When a command or parameter or any other input is not one of a valid list, the CLI simply feeds it, and the valid options, to this Levenshtein calculator and it will return the most likely intended possibilities to display to the user.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
baronfelcommented, Feb 8, 2022

The tab completion support linked in that document is also powered by system.commandline - so the shared data aspect should already be accounted for. In the future we’d like to make tab completion easier to opt into, so that the user doesn’t have to modify their shell profiles at all.

1reaction
baronfelcommented, Feb 8, 2022

We can get this for free from the typo correction middleware in System.CommandLine, which we should do after looking at the impact to the help messages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I received the Command 'dotnet' not found, but can be ...
Provide details about the problem you're experiencing. Include your operating system version, exact error message, code sample, and anything ...
Read more >
Visual Studio Code error - 'dotnet' is not recognized as an ...
If you close VSCode after closing the terminal, the problem will be fixed. But you need to make sure .net is installed. If...
Read more >
dotnet build command - .NET CLI
The dotnet build command builds a project and all of its dependencies.
Read more >
Install the .NET SDK or the .NET Runtime on Ubuntu
Demonstrates the various ways to install .NET SDK and .NET Runtime on Ubuntu.
Read more >
Why dotnet command is not working ? whenever I try to ...
I have already added dotnet in environment path . "dotnet " command working in fine in CMD.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found