rust-lang / rust-lang/rustup

Rustup installs required toolchain when cargo-completion called

Open
#4,959 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
22h 40m
Merged PRs (30d)
46

Description

Verification
Problem
  • Cargo has dynamic completions for shells.
  • Rustup respects rust-toolchain(.toml).
  • ☝🏻this is conflict
rustup default nightly; rustup uninstall stable; 
echo "toolchain.channel = \"stable\"" > rust-toolchain.toml
CARGO_COMPLETE=fish cargo -
# then rustup installs stable toolchain :(
# my shell (fish) completion function: `source (CARGO_COMPLETE=fish cargo | psub)`
Steps
  1. rustup default nightly
  2. echo "toolchain.channel = \"not-yet-installed-toolchain\"" > rust-toolchain.toml
  3. CARGO_COMPLETE=fish cargo -
Possible Solution(s)

My workaround:

source (CARGO_COMPLETE=fish RUSTUP_TOOLCHAIN="nightly" cargo +nightly | psub)
Notes

I suppose rustup should not respects overrides (rust-toolchain(.toml)) if called with non-empty env CARGO_COMPLETE.

Update (thanks, @djc): source (RUSTUP_AUTO_INSTALL=0 CARGO_COMPLETE=fish cargo | psub)

Rustup version
rustup 1.29.0 (28d1352db 2026-03-05)
Installed toolchains
nightly only
OS version
macOs 15.7.7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with rust-toolchain.toml, an uninstalled toolchain, and CARGO_COMPLETE=fish cargo -. Start by tracing how rustup handles toolchain overrides during cargo completion, including the RUSTUP_AUTO_INSTALL workaround. Done means completion works without installing the toolchain selected by rust-toolchain.toml.

Written by the indexing model from the issue text.

Assessment

Tech stack
fish, rust
Domain
cli, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.