Hello, I'm on rust 1.63 installed with a package manager on OpenBSD. I install clap with
cargo add clap
and after cargo build it says
error: package clap_lex v0.3.1 cannot be built because it requires rustc 1.64.0 or newer, while the currently active rustc version is 1.63.0
I want to install some of the latest set [library, its dependences] suitable for my exact version of rustc. I do not want to upgrade rust before my OS gets the newer package.
I don't believe there is a way of saying 'get me the latest version that is compatible with an old Rust' - the rust-version field of Cargo.toml (which is what causes this error message) does not factor into version resolution. There has been discussion of adding that in the past, but it's not something that's currently implemented.
With that in mind, your best bet is to look at the changelog for the library you're trying to use:
There are a couple of potential things to improve here. Most of this centers around improving the MSRV experience. I've been collecting a list of potential solutions in the libc thread.
Thanks. At least that somehow helps. But some libraries has a lot of deps, so that is not that easy on practice.
Anyway, as a novice, I'll learn a lot about libraries and read their docs, at Changelogs
Unfortunately, this will be an endless struggle. Rust doesn't have any features to properly support anything older than latest stable, so trying to use an older version will be fragile and need special care.
I wrote LTS — Cargo add-on // Lib.rs that can rewind the crate index or remove problematic crates that break on old versions. I planned to use msrv stats to create a selective backwards-compatible index, but never finished that.
In the end, I'd recommend uninstalling Rust from your OS, and using Rust from rustup instead. It will be way easier and more compatible.