rustrust-cargoactix-webrust-actix

Rust version for dependencies


I am new to Rust.

I try to build an example project using a dependency

actix-web = "3.3.2"

I must use Rust 1.59.0, as an older Yocto Linux version manages the build, which only has that version of Rust.

The build fails:

package `bytestring v1.3.1` cannot be built because it requires rustc 1.65 or newer, while the currently active rustc version is 1.59.0

Rust 1.59.0 was released in 2022. Actix-web 3.3.2 was released in 2020. How is it possible that an older dependency can not be built using a newer Rust compiler and environment?

How can I use Actix-web with Rust 1.59.0?

I used this Cargo.toml:

[package]
name = "rest-api-rust"
version = "0.1.0"
edition = "2018"
publish = false

[dependencies]
actix-web = "3.3.2"

Solution

  • How is it possible that an older dependency can not be built using a newer Rust compiler and environment?

    https://github.com/actix/actix-net?tab=readme-ov-file#msrv

    Crates in this repo currently have a Minimum Supported Rust Version (MSRV) of 1.65. As a policy, we permit MSRV increases in non-breaking releases.

    The dependency chain is:

    ❯ cargo tree -i bytestring
    bytestring v1.3.1
    └── actix-router v0.2.7
        └── actix-web v3.3.3
    

    The specific version specs are:

    As you can see, actix-router will take up any bytestring up to but excluding 2.0, and since actix doesn't consider MSRV changes to be breakages an old version of actix will use a much more recent and rustc-incompatible version of bytestring. You need to find the last version of bytestring compatible with your MSRV and pin that as your dependency (according to the changelog 1.2.0 bumped the MSRV to 1.57, but that may or may not be true as it doesn't specify any MSRV bump in 1.3 even though you clearly found one).