How to install Rust nightly *without* rust-docs, miri-preview and all other folders except rustc, cargo, rust-std?

rust-docs is 679 MB. I have ~500 MB of space on my device.

Right now I have have fetched the Nightly release and extracted cargo, rustc, and rust-std-x86_64-unknown-linux-gnu folders in a local directory.

I don't have 1 GB for the default Rust toolchain install.

I just intend to use the Rust standard library, and write Rust scripts in .rs files that I will execute without importing and crates, or compling with rustc or cargo -Zscript.

That ain't working without cargo knowing where the rustc executable is in the same parent working directory.

$ cargo/bin/cargo -Zscript ~/bin/script.rs
warning: `package.edition` is unspecified, defaulting to `2021`
error: could not execute process `rustc -vV` (never executed)

Caused by:
  Permission denied (os error 13)

A minimal but managed install will apparently get you in the vicinity of 450M.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --profile minimal 

I don't know if it needs extra space during installation or not.

How can I make sure to not install the rust-docs? I don't need that.

I evidently need to install Nightly for scripting capabilities https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#script.

Minimal doesn't install the docs.

--default-toolchain nightly is the option to choose nightly.

I'll delete the folders I extracted and try that. Right now I only have 417 MB of space on this device.

Does that include the minimal option?

Can you write the whole line out that produces, to the best of your knowledge, the most minimal nightly Rust install available officially?

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --profile minimal --default-toolchain nightly

I freed up some space, got to 1.2 GB of disk space.

$ rustup-init --profile minimal --default-toolchain nightly

info: profile set to 'minimal'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: latest update on 2024-08-07, rust version 1.82.0-nightly (60d146580 2024-08-06)
info: downloading component 'cargo'
  8.9 MiB /   8.9 MiB (100 %)   1.2 MiB/s in  7s ETA:  0s
info: downloading component 'rust-std'
 28.5 MiB /  28.5 MiB (100 %) 960.2 KiB/s in 34s ETA:  0s 
info: downloading component 'rustc'
 70.6 MiB /  70.6 MiB (100 %)   1.1 MiB/s in  1m 33s ETA:  0s 
info: installing component 'cargo'
  8.9 MiB /   8.9 MiB (100 %)   8.1 MiB/s in  1s ETA:  0s
info: installing component 'rust-std'
 28.5 MiB /  28.5 MiB (100 %)   7.4 MiB/s in  3s ETA:  0s
info: installing component 'rustc'
 70.6 MiB /  70.6 MiB (100 %)   7.8 MiB/s in  8s ETA:  0s
info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'

  nightly-x86_64-unknown-linux-gnu installed - rustc 1.82.0-nightly (60d146580 2024-08-06)

According to my math that's 216. I have 732 MB of disk space on the machine now. 468 MB +/-. I can work with that. Thanks.