Help installing an old version of rustc - Edition 2021 errors

Hi there,

Totally new user here so be prepared for some basic questions. I'm in the unenviable position of trying to replicate a Nix setup that uses an old nightly version of Rust, nightly-2021-01-29. So far I've managed to install the compiler and cargo using rustup.

I'm now trying to install cargo-xbuild and the Nix flow that I'm following patches the src/ file to replace edition = "2021" with edition = "2018". This seems to be a workaround to using the old version of the compiler and avoids an error like:

rust-version 1.56 is older than first version (1.62.0) required by the specified edition (2021)

So having compiled using cargo build I then tried installing the package using cargo install --path . and get the edition 2021 error on another package. My full flow is as follows:

$ rustup default nightly-2021-01-29
$ git clone
$ cd cargo-xbuild
$ cargo build
$ cargo install --path .
  Installing cargo-xbuild v0.6.6 (/home/shareefj/git/multicore-qc/tmp/cargo-xbuild)
    Updating index
  Downloaded fastrand v2.0.1
  Downloaded serde_derive v1.0.195
  Downloaded itoa v1.0.10
  Downloaded cfg-if v1.0.0
  Downloaded quote v1.0.35
  Downloaded bitflags v2.4.1
error: failed to compile `cargo-xbuild v0.6.6 (/home/shareefj/git/multicore-qc/tmp/cargo-xbuild)`, intermediate artifacts can be found at `/home/shareefj/git/multicore-qc/tmp/cargo-xbuild/target`

Caused by:
  failed to parse manifest at `/opt/rust/registry/src/`

Caused by:
  rust-version 1.56.0 is older than first version (1.62.0) required by the specified edition (2021)

So this looks like the cargo install step downloads current versions of the required packages which also have edition = "2021" set. Is the way to work around this to somehow pin the packages required in the install step? Can I do that in the Cargo.toml? The Nix installation doesn't seem to have this issue so perhaps they pin packages internally somehow.

You could try the --locked flag to install dependencies as noted in the lockfile of the thing you’re trying to install. cargo install --locked

Thanks! That solved it.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.