Skip to content

Confusing error with rust-version = "1.77" and cargo:: build script syntax #13807

@lukas-code

Description

@lukas-code

Problem

If you set rust-version = "1.77" in Cargo.toml and use the new cargo:: build script syntax, you will get this wonderful error:

error: the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, but the minimum supported Rust version of `foo v0.1.0 (/tmp/foo)` is 1.77.

The workaround is to specify rust-version = "1.77.0", even though 1.77 and 1.77.0 mean exactly the same thing in semver.

Steps

  1. cargo new foo
  2. paste this into Cargo.toml:
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
rust-version = "1.77"

[dependencies]
  1. create build.rs and paste this:
fn main() {
    println!("cargo::rerun-if-changed=.");
}
  1. cargo check

Possible Solution(s)

Maybe replace < with !is_compatible_with here:

if msrv < new_syntax_added_in {

Notes

No response

Version

cargo 1.79.0-nightly (80d5b607d 2024-04-19)
release: 1.79.0-nightly
commit-hash: 80d5b607dde6ef97dfff4e23923822c01d2bb036
commit-date: 2024-04-19
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions