Closed
Description
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
- Set up a basic Rust project with cargo
- Write
cargo build --target
on terminal and then press the TAB key. - 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
epage commentedon Aug 29, 2023
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
weihanglo commentedon Aug 29, 2023
Another idea is we can go with
rustup
way first and fall back torustc --print target-list
.epage commentedon Aug 29, 2023
Is there a reason to prefer rustup? I guess so you can check which targets are actually installed?
weihanglo commentedon Aug 29, 2023
Yes. Completing with installed ones.
rustc --print target-list
now prints 218 target triples which doesn't sounds too friendly.epage commentedon Aug 29, 2023
Yeah, making both do
rustup
and then fallback seems like the idealmkoncek commentedon Aug 29, 2023
By the way, in Fedora, the programmer does not have access to packaged
rustup
, but instead is supposed to install one of the additionalrust-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 commentedon Aug 30, 2023
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 commentedon Aug 30, 2023
@rustbot claim
Auto merge of #12606 - Angelin01:tab-completion-rustup-fallback-rustc…
--target
values #12607Auto merge of #12607 - epage:target, r=weihanglo