Skip to content

Target tab completion invokes rustup #12585

Closed
@mkoncek

Description

@mkoncek

Problem

Invoking cargo build --target <TAB> invokes rustup. Some environments may not have it installed and I do not see why it should be invoked if the tab completion can run equivalent of rustc --print target-list.

Steps

  1. Set up a basic Rust project with cargo
  2. Write cargo build --target on terminal and then press the TAB key.
  3. If rustup is not installed, terminal will print:
    cargo build --target bash: rustup: command not found

Possible Solution(s)

I suppose cargo could return the output of rustc --print target-list

Notes

It is generally a good idea to depend only on the most basic tools, especially if they get the job done right, like rustc does.

Version

cargo 1.71.0
release: 1.71.0
host: x86_64-unknown-linux-gnu
libgit2: 1.6.4 (sys:0.17.1 system)
libcurl: 8.0.1 (sys:0.4.61+curl-8.0.1 system ssl:OpenSSL/3.0.9)
os: Fedora 38.0.0 [64-bit]


<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"Angelin01"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->

Activity

added
C-bugCategory: bug
S-triageStatus: This issue is waiting on initial triage.
on Aug 29, 2023
epage

epage commented on Aug 29, 2023

@epage
Contributor

Interesting, the zsh completions are using rustc --print target-list but the bash ones aren't.

zsh support for targets was added in #8740

bash support was added in #6640

I don't see any references to why different strategies were taken, so it seems like we could consolidate down to just rustc

added
E-easyExperience: Easy
S-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review
and removed
S-triageStatus: This issue is waiting on initial triage.
on Aug 29, 2023
weihanglo

weihanglo commented on Aug 29, 2023

@weihanglo
Member

Another idea is we can go with rustup way first and fall back to rustc --print target-list.

epage

epage commented on Aug 29, 2023

@epage
Contributor

Is there a reason to prefer rustup? I guess so you can check which targets are actually installed?

weihanglo

weihanglo commented on Aug 29, 2023

@weihanglo
Member

Yes. Completing with installed ones. rustc --print target-list now prints 218 target triples which doesn't sounds too friendly.

epage

epage commented on Aug 29, 2023

@epage
Contributor

Yeah, making both do rustup and then fallback seems like the ideal

mkoncek

mkoncek commented on Aug 29, 2023

@mkoncek
Author

By the way, in Fedora, the programmer does not have access to packaged rustup, but instead is supposed to install one of the additional rust-std-static-* packages (see: https://koji.fedoraproject.org/koji/buildinfo?buildID=2278881). But I don't think the upstream Rust project can / should / wants to detect such cases.

Angelin01

Angelin01 commented on Aug 30, 2023

@Angelin01

I can probably whip this up by tomorrow, already have the bash one ready, just need to do some testing with the ZSH one.

Angelin01

Angelin01 commented on Aug 30, 2023

@Angelin01

@rustbot claim

added a commit that references this issue on Aug 31, 2023

Auto merge of #12606 - Angelin01:tab-completion-rustup-fallback-rustc…

11966a4
added a commit that references this issue on Aug 31, 2023

Auto merge of #12607 - epage:target, r=weihanglo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-completionsArea: shell completionsC-bugCategory: bugE-easyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @epage@weihanglo@Angelin01@mkoncek

    Issue actions

      Target tab completion invokes `rustup` · Issue #12585 · rust-lang/cargo