rust-lang/rustup

Allow installing rustup without a toolchain (or allow specifying one)

Closed this issue · 5 comments

I'm building some Docker containers and throwing Rust in there:

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y

This will download and install stable Rust, but I need more control over which version gets installed. Specifically, I'd like to just install rustup, and then install a specific {stable,beta,nightly}-$DATE:

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-toolchains

I'd also be happy if I could pick a specific version straight-off:

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --toolchain=beta-1999-12-31

I'd be happy to contribute if you have a preferred solution and can give some general pointers as to where to look.

My current workaround is to:

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN rustup default "stable-${date}"

Which uses twice the disk space due to #555.

I have the same use case for Ruma's development environment. Not being able to pin a specific version of nightly Rust via rustup-init is causing us pain.

Would allowing a specific toolchain be as simple as removing this line, or is there something else in the code that forces rustup-init to limit the initial toolchain to a channel name?

brson commented

@jimmycuadra Yes, removing that line will allow arbitrary toolchains at install. If we do that though it will make it much easier to generate an error during install by selecting a bogus toolchain so the error handling will have to be considered. I'd be happy to take a patch that just removes that line for now.

The error handling when the default toolchain fails to install needs revisiting in general.

I'd also be happy if I could pick a specific version straight-off:

You can with following command.

$ curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2021-11-17