Skip to content

Command to create rust-toolchain.toml in the current directory #2868

Open
@ian-h-chamberlain

Description

@ian-h-chamberlain

Apologies if this has already been requested, but I couldn't seem to find any issues describing something like it, nor any feature already built-in to rustup to do this. If there is, please feel free to close this issue.

Describe the problem you are trying to solve

Frequently, when I create a new binary project, I want to pin a specific toolchain immediately after initializing the project, e.g.

cargo new --bin some-project
cat >some-project/rust-toolchain.toml <<EOF
[toolchain]
channel = "stable"
EOF

However, I frequently forget the precise format of the toolchain file, and I have to search in rustup documentation to find an example and copy-paste that into my project. It would be nice if there was a simple way to generate a file with reasonable defaults that I could then customize, similar to the generated Cargo.toml created by cargo new or cargo init.

Describe the solution you'd like

Add one more more new rustup commands to create a rust-toolchain.toml in the current directory. I think this could work similarly to rustup override set (take a toolchain argument), or just use the default / currently-set toolchain. The generated file could also include comments that briefly describe some of the fields and link to the documentation.

Notes

Example of one possible workflow:

cargo new --bin some-project
cd some-project
rustup init nightly . # or whatever the syntax of the command looks like

After which the contents of some-project/rust-toolchain.toml would look like this:

# See more keys and their definitions at https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file
[toolchain]
channel = "nightly"
components = []
targets = []
profile = "default"

Some possible command names:

  • rustup new (for parity with cargo new)
  • rustup init (possibly confusing with rustup-init)
  • rustup generate-toolchain-file or similar (very wordy)
  • rustup pin
  • A subcommand or flag to pass to rustup override set ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions