Skip to content

Rustup installs required toolchain when cargo-completion called #4959

Description

@boozook

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions