Skip to content

Explicitly define our Rust MSRV#1365

Open
denisonbarbosa wants to merge 3 commits intomainfrom
pin-rust-version
Open

Explicitly define our Rust MSRV#1365
denisonbarbosa wants to merge 3 commits intomainfrom
pin-rust-version

Conversation

@denisonbarbosa
Copy link
Copy Markdown
Member

Supporting multiple Ubuntu versions means (possibly) supporting multiple rustc versions. Explicitly defining a MSRV helps us control how far we can bump our dependencies.

UDENG-9430

Supporting multiple Ubuntu versions means (possibly) having to support
multiple rustc versions. Explicitly defining a MSRV helps us control how
far we can bump our dependencies.
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.24%. Comparing base (6085fe4) to head (a50dad3).
⚠️ Report is 21 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1365      +/-   ##
==========================================
- Coverage   86.35%   86.24%   -0.11%     
==========================================
  Files          99       99              
  Lines        6690     6690              
  Branches      111      111              
==========================================
- Hits         5777     5770       -7     
- Misses        857      860       +3     
- Partials       56       60       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@denisonbarbosa denisonbarbosa marked this pull request as ready for review March 30, 2026 13:55
nss/Cargo.toml Outdated
name = "nss"
version = "0.1.0"
edition = "2021"
rust-version = "1.82.0"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the docs:

"3" (edition = "2024" default, requires Rust 1.84+): Change the default for resolver.incompatible-rust-versions from allow to fallback

Running cargo check locally on the branch fails with this error

authd test-pr-1365-local  ✗ cargo +1.82.0 check
error: failed to parse manifest at `/home/nooreldeenmansour/Documents/Projects/authd/Cargo.toml`

Caused by:
  feature `edition2024` is required

  The package requires the Cargo feature called `edition2024`, but that feature is not stabilized in this version of Cargo (1.82.0 (8f40fc59f 2024-08-21)).
  Consider trying a newer version of Cargo (this may require the nightly release).
  See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2024 for more information about the status of this feature.

Should rust-version be bumped or that would be breaking?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely spotted! We do have Rust 1.84 in Noble, so I think we can bump our MSRV now. I'll update the PR to also bump the version to 1.84.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed now!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that in Noble, the available Rust versions (deb) is up to 1.82. According to this link https://documentation.ubuntu.com/ubuntu-for-developers/reference/availability/rust/#ubuntu-rust-deb-packages. Unsure if there is an available backport for 1.8.4

Is this CI failure related? https://github.com/canonical/authd/actions/runs/23800681979/job/69359973291?pr=1365#step:5:6194

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... This weird. Looking at https://launchpad.net/ubuntu/noble/+package/rustc-1.84, you can see that the 1.84 version exists in the archive.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. The Ubuntu documentation is seemingly out-of-sync. or I likely misunderstood it. Anyway, I wonder what is the cause of this CI failure. It seems to be related to the dh-cargo/debian cargo wrapper?

I can see different cargo versions being installed in the CI job:

  Setting up cargo-1.84 (1.84.1+dfsg0ubuntu1~bpo2-0ubuntu2.24.04) ...
  Setting up debhelper (13.14.1ubuntu5) ...
  Setting up dh-exec (0.29build1) ...
  Setting up cargo (1.75.0+dfsg0ubuntu1-0ubuntu7.1) ...
  Setting up dh-cargo (31ubuntu1) ...

In order to rely on some important resolver updates of Cargo
(especially when it comes to respecting the MSRV when bumping updates),
we need Rust 2024 edition, which requires Rust >= 1.84. Since Noble has
cargo-1.84 available, we can safely bump the Rust version without
risking FTBFS due to versioning issues.
Some important changes to how MSRV is handled were introduced in Rust
2024.

We need to switch to resolver version 3 in order to have access to
those changes. More information can be found in:
https://rust-lang.github.io/rfcs/3537-msrv-resolver.html

Switching resolvers sometimes require some code changes, which are
integrated in this commit as a result of running "cargo fix --edition"
members = ["nss/"]
exclude = ["vendor_rust/", "authd-oidc-brokers/third_party/libhimmelblau/", "parts/libhimmelblau/build"]
resolver = "2"
resolver = "3"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing the deb build to fail on Noble:

error: failed to parse manifest at /home/runner/work/authd/authd/Cargo.toml
Caused by:
resolver setting 3 is not valid, valid options are "1" or "2"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... This is due to dh-cargo hardcoding the cargo bin path in it's script (whilst also downloading the default cargo package from the archive).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related, Max Gilmour pointed out that rustc-1.91 was backported to Noble and should not be affected by that bug.

Copy link
Copy Markdown
Member Author

@denisonbarbosa denisonbarbosa Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the bugfix that you've mentioned is good news, it doesn't help us, sadly. The new cargo versions use a different binary name (i.e. cargo-1.91) and the cargo wrapper is hardcoded to use /usr/bin/cargo, as you can see here, for example:

if subcmd == "clean":
        logrun(["env", "RUST_BACKTRACE=1", "/usr/bin/cargo"] + list(newargs), check=True)
        if os.path.exists(cargo_home):
            shutil.rmtree(cargo_home)
        return 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned elsewhere, the cargo wrapper shipped with cargo-1.91 also hardcodes /usr/bin/cargo, so we still can't use a newer cargo version on Noble. Until that's fixed, you could try using the regenerate-cargo-lock-file-on-noble script from my devscripts to generate a Cargo.lock that's compatible with the cargo version we use on Noble.

Copy link
Copy Markdown
Member Author

@denisonbarbosa denisonbarbosa Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it wouldn't make much sense in the context of this PR, especially since (before resolver = 3) cargo doesn't really respect the rust_version setting anyway when adding/bumping dependencies... Up until resolver = 2 (if I understood correctly), it will only throw an error when compiling the crate. I'd say we keep this open (maybe move it back to draft?) until we can get this hardcoding issue fixed and then come back to this. Wdyt?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

especially since (before resolver = 3) cargo doesn't really respect the rust_version setting anyway when adding/bumping dependencies

ah, I was not aware. then it indeed doesn't make sense to merge this with resolver = 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants