Skip to content

rust-toolchain should allow setting the equivalent of --profile minimal #2579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Arnavion opened this issue Nov 27, 2020 · 6 comments · Fixed by #2586
Closed

rust-toolchain should allow setting the equivalent of --profile minimal #2579

Arnavion opened this issue Nov 27, 2020 · 6 comments · Fixed by #2586

Comments

@Arnavion
Copy link

Describe the problem you are trying to solve

For things like CI that can make do with the minimal profile but also need additional components, I usually do something like this to install the desired toolchain:

rust_toolchain="$(cat rust-toolchain)"
rustup toolchain install "$rust_toolchain" --profile minimal --component clippy,rustfmt
rustup default "$rust_toolchain"

The new TOML format allows this to be skipped since the first invocation of rustc / cargo will auto-install the toolchain with the required components, except that it does so using the default profile and thus also installs rust-docs.

Describe the solution you'd like

It would be nice if, when rustup installs a new toolchain as a result of a discovered TOML rust-toolchain file, it either defaults to using the minimal profile if components is specified (too late now perhaps due to backward compatibility), or the TOML has a profile field I can set to "minimal", or some other way.

@DJMcNab
Copy link

DJMcNab commented Nov 28, 2020

Does running rustup set profile minimal before running any cargo commands (etc) work?

@Arnavion
Copy link
Author

Arnavion commented Nov 28, 2020

Good idea. Yes, that does work.

$ rustup set profile minimal

info: profile set to 'minimal'

$ cd foo/
$ cat rust-toolchain

[toolchain]
channel = "stable"
components = ["clippy", "rustfmt"]

$ rustc -vV

info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2020-11-19, rust version 1.48.0 (7eac88abb 2020-11-16)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: using up to 500.0 MiB of RAM to unpack components
info: installing component 'clippy'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'

rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0

@kinnison Do you still want this enhancement?

@Arnavion
Copy link
Author

Actually, as part of making a PR to fix it, I've learned that the concept of "profile" is at the global rustup level, not per toolchain.

$ cat ~/.rustup/settings.toml

default_host_triple = "x86_64-unknown-linux-gnu"
default_toolchain = "nightly-x86_64-unknown-linux-gnu"
profile = "minimal"
version = "12"

[overrides]

So this really doesn't make sense in a rust-toolchain file after all. Running rustup set profile or pre-provisioning the ~/.rustup/settings.toml in builders is the right approach.

@DJMcNab
Copy link

DJMcNab commented Nov 29, 2020

It probably would make sense to default to minimal profile in a CI setting anyway, although that might be a breaking change :(

@kinnison
Copy link
Contributor

It'd involve modifying DistributableToolchain::install_from_dist() to support having an Option<Profile> passed in to override the config profile (not entirely hard, just laborious to touch all the relevant callsites) and then adding the profile capability to the toml file and into the OverrideCfg - if people are still interested, I can reopen this and do the PR.

@jyn514
Copy link
Member

jyn514 commented Nov 29, 2020

I would still like this change - rustdoc is looking into building out of tree, and it needs neither clippy nor rustfmt, since clippy isn't used at all and rustfmt will be the wrong version (rust-lang/rust#76419 (comment)). It would be nice not to download them if they'll never be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants