Skip to content

System Rust uses nightly by default instead of stable. #1970

@wyfo

Description

@wyfo

Summary

I've recently migrated from pre-commit to prek, and had the surprise of having a hook failing because of nightly lint.
As traces confirmed it:

2026-04-20T22:00:29.268022Z TRACE Found matching system rust name=nightly-aarch64-apple-darwin
2026-04-20T22:00:29.268045Z TRACE Using system rust rust=/Users/jope/.rustup/toolchains/[email protected]

It is probably caused by the following lines:

let installed = toolchains
.into_iter()
.sorted_unstable_by(|a, b| b.version.cmp(&a.version));

Versions are sorted in reverse order (should use sort_by_key and std::cmp::Reverse btw), and nightly has obviously the greater version.

I think this behavior is quite unexpected (and nightly lints are have caused a lot of troubles). I would expect system to use the same version as the project.

Willing to submit a PR?

  • Yes — I’m willing to open a PR to fix this.

Platform

Darwin 25.4.0 arm64

Version

prek 0.3.9 (3a9b9fe 2026-04-13)

.pre-commit-config.yaml

[[repos]]
repo = "local"

[[repos.hooks]]
id = "fmt"
name = "fmt"
entry = "cargo fmt -- --config \"unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate,format_code_in_doc_comments=true\""
language = "rust"
pass_filenames = false
types_or = ["rust", "toml"]

[[repos.hooks]]
id = "clippy-no-default-features"
name = "clippy-no-default-features"
entry = "cargo clippy --no-default-features --all-targets -- -D warnings"
language = "rust"
pass_filenames = false
types_or = ["rust", "toml"]

Log file

2026-04-20T22:00:29.268022Z TRACE Found matching system rust name=nightly-aarch64-apple-darwin
2026-04-20T22:00:29.268045Z TRACE Using system rust rust=/Users/jope/.rustup/toolchains/[email protected]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions