Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustup completions don't include completions for Cargo #5596

Closed
ricvelozo opened this issue May 31, 2018 · 7 comments
Closed

rustup completions don't include completions for Cargo #5596

ricvelozo opened this issue May 31, 2018 · 7 comments

Comments

@ricvelozo
Copy link

ricvelozo commented May 31, 2018

Rustup completions works fine, but don't include completions for Cargo. The command I used to install:

$ rustup completions zsh > ~/.zfunc/_rustup

I temporarily fixed it by symlinking ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/zsh/site-functions/_cargo to ~/.zfunc/_cargo.

Using zsh in Fedora 28, Rust 1.26.1.

@sfackler
Copy link
Member

sfackler commented Jun 1, 2018

rustup completions generates completions for rustup, not other binaries.

@ricvelozo
Copy link
Author

ricvelozo commented Jun 1, 2018

Exactly. That is the problem. The completions for Cargo are already shipped together with rustup, but not installed, and there is not a simple command to install for the current toolchain. It would be nice if rustup completions installed completions for Cargo too.

@sfackler
Copy link
Member

sfackler commented Jun 1, 2018 via email

@max-sixty
Copy link

I didn't think this was worth a new issue, so adding here.

Has anyone had any success with completions for cargo using fish? My rustup completions work great, but cargo gives a very odd set of choices:

image

@pierrechevalier83
Copy link

I was just about to report the same issue. Let me add a bit of info I just gathered.

I can reproduce it very easily on a clean ubuntu 18.04 VM by doing the following:
sudo apt install fish cargo
fish
cargo and then hit tabulation.
I get:

benchExecuteallbenchmarksofalocalpackage                                        
buildCompilealocalpackageandallofitsdependencies                                
checkCheckalocalpackageandallofitsdependenciesforerrors                         
cleanRemoveartifactsthatcargohasgeneratedinthepast                              
…and 26 more rows

It seems related to the output of cargo --list.

Additional info: with ubuntu 18.04, fish is at version 2.7.1 and cargo is at version 1.30.0.
I can also reproduce on ubuntu 18.10 with same fish and cargo 1.31.0.

BTW, @killercup, this is what I was mentioning this weekend in case you're interested.

@pierrechevalier83
Copy link

pierrechevalier83 commented Dec 18, 2018

I found the issue. It's a problem in fish 2.7.1's completion file for cargo: https://github.com/fish-shell/fish-shell/blob/b680db8ce683db285c750ae5af534c97d08b1b40/share/completions/cargo.fish#L10

It's already been fixed on fish's master: https://github.com/fish-shell/fish-shell/blob/082450b1e711c75f6722bf7d8651cda8f835fd1e/share/completions/cargo.fish#L10

So the workaround is to apply this diff:

10c10
< set __fish_cargo_subcommands (cargo --list | tail -n +2 | tr -d " ")
---
> set __fish_cargo_subcommands (cargo --list | tail -n +2 | string trim | string replace -r '\s+' '\t')

to /usr/share/fish/completions/cargo.fish (on Ubuntu. YMMV. If it does, locate cargo.fish is your friend 😉 )

The clean fix would be to wait for the next fish release, I guess. Not a bug in cargo 😃

I am not recommending this issue is closed as this was simply a hijack of the original issue; but for the fish problem, the mystery is cleared 😄

Hope this helps, @max-sixty 😄

@ehuss
Copy link
Contributor

ehuss commented Apr 25, 2019

Closing this as I believe rustup can now update completions as of rust-lang/rustup#1646.

@ehuss ehuss closed this as completed Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants