rust-lang / rust-lang/rustup

Mechanism to switch `~/.cargo/config.toml`/`.cargo/config.toml` based on channel

Open
#4,047 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Problem you are trying to solve

There are some options I like to enable globally when using cargo (via cargo's config.toml):

  1. rustflags = ["-C", "link-arg=-fuse-ld=/usr/sbin/mold"] (for all channels)
  2. rustflags = ["-Z", "threads=<N>"] (for nightly only)

I've tried:

  1. To set RUSTFLAGS via rust-toolchain.toml (not an option)
  2. To specify channel in cargo's config.toml (not possible, cargo doesn't understand the idea of multiple toolchains)
  3. To set a .cargo/config.toml in each individual crate (inefficient, and if I decide to try using +stable in a +nightly-configured crate, I get an error)

-Z threads=<N> will eventually land in stable, but I can envision similar feature incompatibilities between the channels in the future.

Solution you'd like

Much like the cargo binary is swapped out by rustup, I'd like an option to swap out config.toml files as if I really was using a fully isolated and separate toolchain.

It could be that rustup has an equivalent location to where cargo will look for config.toml for each toolchain, but it's not clear if this file will be preserved between installation/updates/removal.

Notes

I can see a few ways to approach this, but they all have pros/cons so I'm curious to hear from rustup devs what their thoughts are.

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

No files, tests, or entry points are named. Start by reviewing how rustup selects toolchains and how Cargo discovers config.toml files, then discuss the proposed channel-specific configuration mechanism with maintainers; done means an agreed design and implementation scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.