{"id":13594987,"url":"https://github.com/foresterre/cargo-msrv","last_synced_at":"2025-05-13T22:05:13.303Z","repository":{"id":37794476,"uuid":"211614229","full_name":"foresterre/cargo-msrv","owner":"foresterre","description":"🦀 Find the minimum supported Rust version (MSRV) for your project","archived":false,"fork":false,"pushed_at":"2025-04-21T20:49:46.000Z","size":4845,"stargazers_count":1013,"open_issues_count":76,"forks_count":40,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-21T21:38:47.401Z","etag":null,"topics":["cargo","cargo-msrv","cli","hacktoberfest","msrv","rust","rust-lang","rust-tools"],"latest_commit_sha":null,"homepage":"https://foresterre.github.io/cargo-msrv","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foresterre.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["foresterre"],"buy_me_a_coffee":"foresterre","thanks_dev":"u/gh/foresterre"}},"created_at":"2019-09-29T06:24:29.000Z","updated_at":"2025-04-21T20:48:42.000Z","dependencies_parsed_at":"2022-07-10T15:17:34.749Z","dependency_job_id":"d62a72fa-5d77-47f2-a09c-83c28db42af3","html_url":"https://github.com/foresterre/cargo-msrv","commit_stats":{"total_commits":701,"total_committers":21,"mean_commits":33.38095238095238,"dds":"0.39657631954350925","last_synced_commit":"ed9518dfe595669c62d19084d6e6754c7edcb460"},"previous_names":[],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresterre%2Fcargo-msrv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresterre%2Fcargo-msrv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresterre%2Fcargo-msrv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresterre%2Fcargo-msrv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foresterre","download_url":"https://codeload.github.com/foresterre/cargo-msrv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251341309,"owners_count":21574094,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cargo","cargo-msrv","cli","hacktoberfest","msrv","rust","rust-lang","rust-tools"],"created_at":"2024-08-01T16:01:41.982Z","updated_at":"2025-05-13T22:05:13.293Z","avatar_url":"https://github.com/foresterre.png","language":"Rust","funding_links":["https://github.com/sponsors/foresterre","https://buymeacoffee.com/foresterre","https://thanks.dev/u/gh/foresterre"],"categories":["Rust"],"sub_categories":[],"readme":"# cargo-msrv\n\nThis crate can assist you in finding the Minimum Supported Rust Version for a crate.\n\nIn this readme you'll find everything to get you started. You can find more detailed explanations in the\n[cargo-msrv book](https://foresterre.github.io/cargo-msrv/index.html).\n\n### Preview\n\n\u003csup\u003e\u003cstrong\u003e⌘\u003c/strong\u003e [preview](#preview) - [prerequisites](#prerequisites) - [install](#install) - [usage](#usage) - [JSON output format](#json-format) - [a short history](#a-short-history) - [license](#license)\u003c/sup\u003e\n\n[![asciicast](https://asciinema.org/a/679852.svg)](https://asciinema.org/a/679852)\n\n### Prerequisites\n\n\u003csup\u003e⌘ [preview](#preview) - [prerequisites](#prerequisites) - [install](#install) - [usage](#usage) - [JSON output format](#json-format) - [a short history](#a-short-history) - [license](#license)\u003c/sup\u003e\n\n[Rustup](https://rustup.rs/) is required for the `cargo msrv (find)` and `cargo msrv verify` commands.\n\n### Install\n\n\u003csup\u003e⌘ [preview](#preview) - [prerequisites](#prerequisites) - [install](#install) - [usage](#usage) - [JSON output format](#json-format) - [a short history](#a-short-history) - [license](#license)\u003c/sup\u003e\n\n#### cargo ([crates.io source](https://crates.io/crates/cargo-msrv))\n\n| cargo       | supported | command                               |\n|-------------|-----------|---------------------------------------|\n| stable      | 💚        | `$ cargo install cargo-msrv --locked` |\n| development | ❌        |                                       |\n\n#### cargo ([git source](https://github.com/foresterre/cargo-msrv))\n\n| cargo       | supported | command                                                                                       |\n|-------------|-----------|-----------------------------------------------------------------------------------------------|\n| stable      | 💚        | `$ cargo install --git https://github.com/foresterre/cargo-msrv.git --tag v0.18.4` cargo-msrv |\n| development | 💚        | `$ cargo install --git https://github.com/foresterre/cargo-msrv.git` cargo-msrv               |\n\n#### [cargo-binstall](https://github.com/cargo-bins/cargo-binstall)\n\n| cargo       | supported | command                                                     |\n|-------------|-----------|-------------------------------------------------------------|\n| stable      | 💚        | `$ cargo binstall --version 0.18.4 --no-confirm cargo-msrv` |\n| development | ❌        |                                                             |\n\n#### Arch Linux [extra repository](https://archlinux.org/packages/extra/x86_64/cargo-msrv/)\n\n* `pacman -S cargo-msrv`\n\n#### Docker\n\nYou can use the following commands for building and running via Docker:\n\n* `$ docker build -t cargo-msrv .`\n* `$ docker run -t -v \"$(pwd)/Cargo.toml\":/app/Cargo.toml cargo-msrv`\n\nDocker images are also available on [Docker Hub](https://hub.docker.com/r/foresterre/cargo-msrv).\n\n### Usage\n\n\u003csup\u003e⌘ [preview](#preview) - [prerequisites](#prerequisites) - [install](#install) - [usage](#usage) - [JSON output format](#json-format) - [a short history](#a-short-history) - [license](#license)\u003c/sup\u003e\n\n* [`cargo msrv find`](https://foresterre.github.io/cargo-msrv/commands/find.html)\n  or [`cargo msrv find --linear`](https://foresterre.github.io/cargo-msrv/commands/find.html) to find the MSRV for a\n  Cargo project in your current working directory.\n* [`cargo msrv --path \u003cdir\u003e find`](https://foresterre.github.io/cargo-msrv/commands/find.html) to find the MSRV for a\n  Cargo project in the `\u003cdir\u003e` directory.\n* [`cargo msrv find -- \u003ccommand\u003e`](https://foresterre.github.io/cargo-msrv/commands/find.html) to use `\u003ccommand\u003e` as the\n  compatibility check which decides whether a Rust version is\n  compatible or not. This command should be runnable through rustup as `rustup run \u003ctoolchain\u003e \u003ccommand\u003e`.\n    * Example: `cargo msrv find -- cargo check --tests`.\n    * Example: `cargo msrv find -- cargo check --ignore-rust-version`. Only available on Rust \u003e= 1.56.\n* [`cargo msrv verify`](https://foresterre.github.io/cargo-msrv/commands/verify.html)  to verify the MSRV as specified\n  by a crate author\\\n    * A crate author may specify the MSRV using the `package.rust-version` (Rust \u003e=1.56) or the `package.metadata.msrv`\n      key in the 'Cargo.toml' manifest. See\n      the [book](https://foresterre.github.io/cargo-msrv/commands/list.html#description) for a more detailed\n      description.\n* [`cargo msrv list`](https://foresterre.github.io/cargo-msrv/commands/list.html) to list the MSRV's of your\n  dependencies as specified by their authors\n* [`cargo msrv show`](https://foresterre.github.io/cargo-msrv/commands/show.html) to show the currently specified MSRV\n\nPlease refer to the [commands](https://foresterre.github.io/cargo-msrv/commands/index.html) chapter in the cargo-msrv\nbook for more detailed descriptions of the supported (sub) commands.\n\n**Options**\n\n```\nFind your Minimum Supported Rust Version!\n\nUsage: cargo msrv [OPTIONS] \u003cCOMMAND\u003e\n\nCommands:\n  find    Find the MSRV\n  list    Display the MSRV's of dependencies\n  set     Set the MSRV of the current crate to a given Rust version\n  show    Show the MSRV of your crate, as specified in the Cargo manifest\n  verify  Verify whether the MSRV is satisfiable\n  help    Print this message or the help of the given subcommand(s)\n\nOptions:\n      --path \u003cCrate Directory\u003e\n          Path to cargo project directory\n\n      --manifest-path \u003cCargo Manifest\u003e\n          Path to cargo manifest file\n\n  -h, --help\n          Print help (see a summary with '-h')\n\n  -V, --version\n          Print version\n\nUser output options:\n      --output-format \u003cFORMAT\u003e\n          Set the format of user output\n\n          [default: human]\n\n          Possible values:\n          - human:   Progress bar rendered to stderr\n          - json:    Json status updates printed to stdout\n          - minimal: Minimal output, usually just the result, such as the MSRV or whether verify succeeded or failed\n\n      --no-user-output\n          Disable user output\n\nDebug output options:\n      --no-log\n          Disable logging\n\n      --log-target \u003cLOG TARGET\u003e\n          Specify where the program should output its logs\n\n          [default: file]\n          [possible values: file, stdout]\n\n      --log-level \u003cLEVEL\u003e\n          Specify the severity of logs which should be\n\n          [default: info]\n          [possible values: trace, debug, info, warn, error]\n\n\n            You may provide a custom compatibility `check` command as the last argument (only\n            when this argument is provided via the double dash syntax, e.g. `$ cargo msrv -- custom\n            command`.\n            This custom check command will then be used to validate whether a Rust version is\n            compatible.\n            A custom `check` command should be runnable by rustup, as they will be passed on to\n            rustup like so: `rustup run \u003ctoolchain\u003e \u003cCOMMAND...\u003e`. NB: You only need to provide the\n            \u003cCOMMAND...\u003e part.\n\n            By default, the custom check command is `cargo check`.\n```\n\n### JSON format\n\n\u003csup\u003e⌘ [preview](#preview) - [prerequisites](#prerequisites) - [install](#install) - [usage](#usage) - [JSON output format](#json-format) - [a short history](#a-short-history) - [license](#license)\u003c/sup\u003e\n\nJSON output may be enabled by providing the `--output-format json` flag: `cargo msrv find --output-format json`.\nEvents are printed as json lines. The event type is indicated by the `type` key.\n\nPlease see the [Output formats](https://foresterre.github.io/cargo-msrv/output-formats/index.html) and\n[Output format: JSON](https://foresterre.github.io/cargo-msrv/output-formats/json.html) chapters of the\nbook for documentation of this output format.\n\n### A short history\n\n\u003csup\u003e⌘ [preview](#preview) - [prerequisites](#prerequisites) - [install](#install) - [usage](#usage) - [JSON output format](#json-format) - [a short history](#a-short-history) - [license](#license)\u003c/sup\u003e\n\n_An [excerpt](https://foresterre.github.io/posts/puzzle-sharing-declarative-args-between-top-level-and-subcommand/)_\n\n\u003e `cargo-msrv` was originally born out of a desire to find the MSRV for a Rust project (more specifically package). MSRV\n\u003e stands for \"minimal supported Rust version\" and is the earliest or oldest version supported by a Rust project. For\n\u003e different projects this may mean different things, but for this post I will consider \"support\" as \"does compile with a\n\u003e Rust toolchain of a certain version\".\n\u003e\n\u003e Fast forward a few years, and the MSRV has become somewhat more ubiquitous which can also be seen by its inclusion\n\u003e into Cargo as the [rust-version](https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field). Over\n\u003e time some additional tools were added to `cargo-msrv`. One of these was the `cargo msrv verify` subcommand.\n\u003e\n\u003e This subcommand can be used to check whether a Rust project supports its defined MSRV (e.g. via this `rust-version`\n\u003e field in the Cargo manifest). For example, in a CI pipeline you can use this to check whether your project works for\n\u003e the\n\u003e version you promised to your users.\n\u003e\n\u003e Originally, I kept the `cargo msrv` top level command aside from the subcommands for backwards compatibility reasons.\n\u003e In hindsight I probably shouldn't have done that, but as is, their coexistence at least provides me with the\n\u003e opportunity\n\u003e to write this blog post 😅.\n\u003e\n\u003e **How cargo msrv works**\n\u003e\n\u003eI described the \"support\" from \"minimal supported Rust version\" (MSRV) above as the somewhat simplified \"does compile\n\u003e with a Rust toolchain of a certain version\".\n\u003e\n\u003eYou may write that as a function like so:  `fn is_compatible(version) -\u003e bool`. If you run this test for some Rust\n\u003e version, when the function produces the value `true`, then we consider the Rust version to be supported. If instead\n\u003e the\n\u003e function produces the value `false`, then the Rust version is not supported.\n\u003e\n\u003e`cargo msrv` specifically searches for the _minimal_ Rust version which is supported by a given Rust project. While\n\u003e there are some caveats, we build upon\n\u003e Rust's [stability promise](https://blog.rust-lang.org/2014/10/30/Stability.html#committing-to-stability) . In our case\n\u003e that is the idea that Rust versions are backwards compatible.\n\u003e\n\u003eFor a simple example to determine an MSRV, you can linearly walk backwards from the most recent Rust version to the\n\u003e earliest. When your project doesn't compile for a specific Rust version, then the last version that did compile can be\n\u003e considered your MSRV.\n\u003e\n\u003eLet's make it a bit more concrete with an example. For this example, we assume that Rust the following Rust versions\n\u003e exist: `1.0.0` up to and including `1.5.0`.\n\u003e\n\u003eConsider a project which uses the [Duration](https://doc.rust-lang.org/std/time/struct.Duration.html#) API which was\n\u003e stabilised by [Rust 1.3.0](https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-130-2015-09-17) (and\n\u003e nothing more recent 😉).\n\u003e\n\u003eThen, if you would compile this project with Rust version from most recent to least recent, you would expect the\n\u003e following to happen:\n\u003e\n\u003e- `is_compatible(Rust 1.5.0)` returns `true` ✅\n\u003e- `is_compatible(Rust 1.4.0)` returns `true` ✅\n\u003e- `is_compatible(Rust 1.3.0)` returns `true` ✅\n\u003e- `is_compatible(Rust 1.2.0)` returns `false` ❌ (\"Duration is not stable\")\n\u003e- `is_compatible(Rust 1.1.0)` returns `false` ❌\n\u003e- `is_compatible(Rust 1.0.0)` returns `false` ❌\n\u003e\n\u003eSince we only care about the _minimal_ Rust version, you could have stopped searching after compiling Rust 1.2.0; Rust\n\u003e 1.3.0 was the earliest released Rust version which worked.\n\u003e\n\u003eIn reality doing a linear search is quite slow (at the time of writing, there are 79 minor versions), so we primarily\n\u003e use a binary search instead to incrementally reduce the search space.\n\u003e\n\u003e`cargo msrv verify` works quite similar to \"finding the MSRV\", but instead of running a search which produces as\n\u003e primary output the MSRV, in this case the MSRV is already known in advance. So given a `MSRV` of `1.3.0` we just run\n\u003e the\n`is_compatible(Rust 1.3.0)` function once. If it returns `true` we can say that the 1.3.0 is an acceptable MSRV (\n\u003e although not necessarily strictly so). More importantly, if it returns false, then the specified version is actually\n\u003e not\n\u003e supported, and thus can not be an MSRV).\n\n### License\n\n\u003csup\u003e⌘ [preview](#preview) - [prerequisites](#prerequisites) - [install](#install) - [usage](#usage) - [JSON output format](#json-format) - [a short history](#a-short-history) - [license](#license)\u003c/sup\u003e\n\nLicensed under either of\n\n* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n#### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in the work by you, as defined in the Apache-2.0\nlicense, shall be dual licensed as above, without any additional terms or\nconditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforesterre%2Fcargo-msrv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforesterre%2Fcargo-msrv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforesterre%2Fcargo-msrv/lists"}