rust-lang / rustup

The Rust toolchain installer
https://rust-lang.github.io/rustup/
Apache License 2.0
6.08k stars 875 forks source link

Nightly toolchain version is off by one #3455

Open safinaskar opened 1 year ago

safinaskar commented 1 year ago

Problem

I have a host A and a host B. Host A has rust installed. Host B - not. I decided to install on host B the same rust version host A has. So I typed this on host A:

$ rustc --version
rustc 1.72.0-nightly (e6d4725c7 2023-06-05)

Then I copied 2023-06-05 from output above and typed this to host B:

# curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain nightly-2023-06-05
info: downloading installer
info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'nightly-2023-06-05-x86_64-unknown-linux-gnu'
info: latest update on 2023-06-05, rust version 1.72.0-nightly (101fa903b 2023-06-04)
info: downloading component 'cargo'
  7.0 MiB /   7.0 MiB (100 %)   1.0 MiB/s in 12s ETA:  0s
info: downloading component 'clippy'
  2.4 MiB /   2.4 MiB (100 %)   1.0 MiB/s in  4s ETA:  0s
info: downloading component 'rust-docs'
 13.6 MiB /  13.6 MiB (100 %)   1.0 MiB/s in 20s ETA:  0s
info: downloading component 'rust-std'
 26.4 MiB /  26.4 MiB (100 %)   1.0 MiB/s in 43s ETA:  0s
info: downloading component 'rustc'
 63.7 MiB /  63.7 MiB (100 %)   1.0 MiB/s in  1m 47s ETA:  0s 
info: downloading component 'rustfmt'
  2.3 MiB /   2.3 MiB (100 %)   1.0 MiB/s in  4s ETA:  0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 13.6 MiB /  13.6 MiB (100 %)   1.6 MiB/s in 10s ETA:  0s
info: installing component 'rust-std'
 26.4 MiB /  26.4 MiB (100 %)  11.2 MiB/s in  2s ETA:  0s
info: installing component 'rustc'
 63.7 MiB /  63.7 MiB (100 %)  12.2 MiB/s in  5s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'nightly-2023-06-05-x86_64-unknown-linux-gnu'

  nightly-2023-06-05-x86_64-unknown-linux-gnu installed - rustc 1.72.0-nightly (101fa903b 2023-06-04)

Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source "$HOME/.cargo/env"
# source "$HOME/.cargo/env"
# rustc --version
rustc 1.72.0-nightly (101fa903b 2023-06-04)

As you can see original version (rustc 1.72.0-nightly (e6d4725c7 2023-06-05)) differs from host B's version (rustc 1.72.0-nightly (101fa903b 2023-06-04)).

So, something really wrong happens here. I don't know whether there is a bug in rustup itself or just in documentation

Steps

-

Possible Solution(s)

No response

Notes

No response

Rustup version

-

Installed toolchains

-
rami3l commented 1 year ago

@safinaskar Thanks for your report! However, this is not a bug but a feature.

The 2023-06-05 that you see in rustc --version is the date of the commit e6d4725c7. At 0:00 UTC of 2023-06-06, the CI has built a toolchain (which is the one that you installed on the first machine) up to that final commit, so the right toolchain to install is nightly-2023-06-06-x86_64-unknown-linux-gnu.

safinaskar commented 1 year ago

@rami3l , okay, how to install to host B rustc version, which is equal to A's version without the need to perform calendar calculations in head?

rami3l commented 1 year ago

@safinaskar If you need calendar calculations for CI workflows for example, you can use the date command. This post should include exactly what you need.

However, inspecting the output of rustc --version is not the standard way of keeping rust toolchains in sync across machines. You might want to use the toolchain file instead.

safinaskar commented 1 year ago

:( :( :( This is very bad

rbtcollins commented 1 year ago

This is a little challenging yes. If you were dealing with released versions it would be quite trivial.

For nightly, if host A had a named toolchain installed, which rustup toolchains list would show, then you would have the right metadata to copy over to host B. If on the other hand you just had the floating version nightly, then I don't think we have enough metadata to infer the matching date based channel from that - though I could be wrong.

rami3l commented 10 months ago

This is a duplicate of https://github.com/rust-lang/rustup/issues/1637 and https://github.com/rust-lang/rust/issues/51533, but I'd like to keep it open for tracking purposes.

Possibly related to #977.