Cargo: rustup completions don't include completions for Cargo

Created on 31 May 2018  Â·  7Comments  Â·  Source: rust-lang/cargo

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.

Most helpful comment

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

All 7 comments

rustup completions generates completions for rustup, not other binaries.

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.

Sounds like that would be an issue to file on the rustup repo then, right?
On Fri, Jun 1, 2018 at 12:18 AM Ricardo Veloso notifications@github.com
wrote:

Exactly. That is the problem. The completions for Cargo are 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.

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/rust-lang/cargo/issues/5596#issuecomment-393787918,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABY2UWQLZdjgFnCW2Yqa09SEdI-KyrnAks5t4OrQgaJpZM4UUfzA
.

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

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:

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.

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:

< 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 :wink: )

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

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 :smile:

Hope this helps, @max-sixty :smile:

Closing this as I believe rustup can now update completions as of https://github.com/rust-lang/rustup.rs/pull/1646.

Was this page helpful?
0 / 5 - 0 ratings