Skip to content

doc: Update instructions on using native-completions #15480

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PRO-2684
Copy link

@PRO-2684 PRO-2684 commented May 2, 2025

~/.local/share/bash-completion/completions/cargo is more sensible, and recommended by rustup.

@rustbot
Copy link
Collaborator

rustbot commented May 2, 2025

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-documenting-cargo-itself Area: Cargo's documentation S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 2, 2025
@epage
Copy link
Contributor

epage commented May 2, 2025

I'm not too familiar with how the different completion locations are loaded.

So you are saying the following ~/.local/share/bash-completion/completions/cargo will work:

source <(CARGO_COMPLETE=bash cargo +nightly)

Have you tested this?

Its important to note that we are not telling people to

$ CARGO_COMPLETE=bash cargo +nightly > ~/.local/share/bash-completion/completions/cargo

And speaking of rustup, why does it have you append to the file? That seems bad if the person forgets and does it again

@epage
Copy link
Contributor

epage commented May 2, 2025

Hmm, looking into that documentation in rustup, it is to conform to https://github.com/scop/bash-completion/blob/main/README.md

My question would then be how often is that installed and used?

@@ -1816,10 +1816,10 @@ When in doubt, you can discuss this in [#14520](https://github.com/rust-lang/car

### How to use native-completions feature:
- bash:
Add `source <(CARGO_COMPLETE=bash cargo +nightly)` to your .bashrc.
Add `source <(CARGO_COMPLETE=bash cargo +nightly)` to `~/.local/share/bash-completion/completions/cargo`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or make it XDG_DATA_HOME, which

Copy link
Author

@PRO-2684 PRO-2684 May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or make it XDG_DATA_HOME

Maybe some fallback method should be mentioned, in case the env var doesn't exist?

Copy link
Author

@PRO-2684 PRO-2684 May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the code, the .local/share directory will be used as a fallback for XDG_DATA_HOME.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggested fallback of XDG_DATA_HOME is exactly $HOME/.local/share. I think saying XDG_DATA_HOME is good enough, alike elvish and fish.

https://specifications.freedesktop.org/basedir-spec/latest/#variables

@PRO-2684
Copy link
Author

PRO-2684 commented May 3, 2025

Have you tested this?

I've tested it on Ubuntu 24.04.2 LTS, with bash 5.2.21 and bash-completion 2.11-8.

@PRO-2684
Copy link
Author

PRO-2684 commented May 3, 2025

And speaking of rustup, why does it have you append to the file? That seems bad if the person forgets and does it again

Regarding that they used > in zsh, I suspect it's a typo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants