Skip to content

dotnet-suggest either no results at all or an error #794

Closed

Description

@erichiller

I haven't been able to get dotnet-suggest working> My command is listed by dotnet-suggest list however use yields nothing, example ./mycmd.exe <TAB> yields nothing (it will just list the files in the directory) when I actually have several top level commands (attached to root).

I tried it with with dotnet ef <TAB> and it errored oddly - it said something about index outside array, and the error actually filled the command prompt line so that if I pressed the up arrow it would take me line by line through the exception message.

Let me know if there is any other information I can gather for you.

btw the version:

post -- dotnet-suggest.exe --version
1.1.110402+ee740ce93caef56482d900984746ae86c205fa7e

Activity

  1. jonsequitur commented on Feb 21, 2020

    @jonsequitur
    Contributor

    What shell/terminal are you using?

  2. jonsequitur commented on Feb 21, 2020

    @jonsequitur
    Contributor

    Also, I don't believe dotnet-ef uses System.CommandLine so completions with dotnet-suggest will not be available.

  3. added
    Area-Completions
    on Feb 21, 2020
  4. erichiller commented on Feb 22, 2020

    @erichiller
    Author

    If I run dotnet-suggest list I get this output:

    dotnet-ef
    dotnet ef
    dotnet-suggest
    dotnet suggest
    mkmrk.cli
    

    So I assumed dotnet-ef was a valid command to try for dotnet-suggest

    Directory no.1 (has no .csproj file in it) = try dotnet-ef.exe <TAB> adds to the same line as I typed dotnet-ef.exe <TAB> : No project was found. Change the current working directory or use the --project No project was found. Change the current working directory or use the --project option.

    Directory no.2 (does have a .csproj) with no appended .exe =

    dotnet-ef
    System.IndexOutOfRangeException: Index was outside the bounds of the array.
    at System.String.get_Chars(Int32 index)
    at Microsoft.EntityFrameworkCore.Tools.RootCommand.<>c.<Execute>b__11_0(String a)
    at System.Linq.Enumerable.TakeWhileIterator[TSource](IEnumerable`1 source, Func`2 predicate)+MoveNext()
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute()
    at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0()
    at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
    at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
    Index was outside the bounds of the array.
    

    Directory no.2 with .exe appended:
    It slows down a ton and then repeated prints:

    dotnet-ef.exe .\
    Build started...                                              Specify --help for a list of available options and commands.
    Build succeeded.                                              Unrecognized command or argument '[suggest:6]'
    

    Until I ctrl-c

    For my program it just pauses a brief second and then appends .\ to the command line and prints out the files like:

    .\prgm.cli .\
    appsettings.json                                             prgm.cli.dll
    EFCore.NamingConventions.dll                                 prgm.cli.exe
    

    The above was with Windows Terminal and I had loaded my profile.ps1 which does change some PSReadLine settings. I also tried this in ConEmu.

    I tried with vanilla Windows PowerShell.exe and no profile - same action for my program, except the files don't print out (because PSReadLine isn't configured to do so). For dotnet-ef it was as if it was not doing anything, just cycled through the files in the directory (in directory no1)

  5. jonsequitur commented on Feb 22, 2020

    @jonsequitur
    Contributor

    It looks like dotnet-suggest will have a registration for any dotnet- prefixed tool but they'll only work if they're using System.CommandLine. I see a number of other registrations when I run dotnet-suggest list that I know won't work.

    But dotnet-suggest is dotnet-suggest enabled. Does dotnet-suggest <TAB> show you completions?

  6. erichiller commented on Feb 22, 2020

    @erichiller
    Author

    No, same behavior, it will just cycle through files.

  7. adamhewitt627 commented on Mar 6, 2020

    @adamhewitt627
    Member

    I'm seeing this as well: mycli.exe [TAB] yields no suggestions beyond the files in the current directory. Same story even with this example.

    • I haven't ruled out that there's something I am missing in a local configuration, but it's unclear what or where to look.
    • Since the VS Code terminal shows the running tool, I do see dotnet-suggest launch there, but it doesn't suggest any results.

    Project

      <PropertyGroup>
        <TargetFramework>netcoreapp3.0</TargetFramework>
        <OutputType>Exe</OutputType>
        <PublishSingleFile>true</PublishSingleFile>
      </PropertyGroup>

    Build

    PS > dotnet publish -c Release -r win-x64
    
    PS > .\mycli.exe [TAB]  #suggests files
    PS > .\mycli.exe --[TAB] #no response

    Terminal

    Same behavior in VS Code terminal, Windows Terminal, and Windows PowerShell.

    PS > $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSVersion                      6.2.4
    PSEdition                      Core
    GitCommitId                    6.2.4
    OS                             Microsoft Windows 10.0.18362
    Platform                       Win32NT
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    WSManStackVersion              3.0

    dotnet-suggest

    PS > dotnet suggest list
    
    dotnet-ef
    dotnet ef
    dotnet-suggest
    dotnet suggest
    mycli
    testhost
    
    PS >dotnet suggest get -e mycli.exe
    PS >    # no output, just moves on to next input
  8. jonsequitur commented on Mar 8, 2020

    @jonsequitur
    Contributor

    Can you try running the following and afterward rechecking whether tab completion returns results?

    > mycli.exe [suggest]
  9. adamhewitt627 commented on Mar 9, 2020

    @adamhewitt627
    Member

    It took 10-15s to complete, and did output this. However, tab completion is still not working.

    PS > .\mycli.exe [suggest]
    --force
    --help
    --output
    --output-type
    --source
    --source-type
    --version
    -?
    -f
    -h
    -o
    -s
    /?
    /h
  10. adamhewitt627 commented on Mar 9, 2020

    @adamhewitt627
    Member

    Same behavior under WSL2, Ubuntu 18.04.2 LTS, including with the suggestion to run mycli [suggest]. I can also assert that the bash_profile is running, as I tried adding it without remembering to install .NET and got errors. (Which then disappeared after relaunching the terminal)

    @Keboo tells me this should be my first PR, but I'm not entirely sure how to get started, particularly with getting suggestions to point at the local checkout rather than the installed tool. Between CONTRIBUTING.md and documentation, I can probably figure it out, but wouldn't mind tips if you have them.

  11. jonsequitur commented on Mar 18, 2020

    @jonsequitur
    Contributor

    I'd be happy to help you investigate and prepare a PR. It would be very helpful as I don't have an Ubuntu machine set up.

    The first thing to do is install a local build of dotnet-suggest, by running C:\dev\command-line-api\src\System.CommandLine.Suggest\build-and-install.ps1 or equivalent. We don't have a sh version but the script is quite simple. The debug build will write a log file if the DOTNET_SUGGEST_LOGGING environment variable is set. You can see how it works here: https://github.com/dotnet/command-line-api/blob/master/src/System.CommandLine.Suggest/Program.cs

    The overall call flow looks like this:

    > mycli.exe sou<tab> --> shell script -> dotnet-suggest get -e /path/to/mycli --position 3 -- sou --> mycli.exe [suggest:3] sou

    You'll see something like this in the log file:

    dotnet-suggest received: |get|-e|/path/to/mycli.exe|--position|3|--|mycli.exe
    dotnet-suggest received: |[suggest:3]|sou
    dotnet-suggest returning: "--source\n--source-type"
    

    At this point you should be able to tell where things are breaking down.

  12. erichiller commented on Aug 4, 2020

    @erichiller
    Author

    Most recent dotnet-suggest and System.CommandLine seem to have fixed this for me at least. I can't say exactly which version fixed it as I had been away from my project for a while.
    Curious if upgrading has fixed others' issues? If so, we can close this I think.

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

    Area-Completionswaiting-on-feedback

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions