rust-lang / rust-lang/cargo

Ability to exclude a version in my version requirement

Open
#5,286 7 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-crate-dependencies C-feature-request S-propose-close
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Hello

I maintain a library and it was discovered that it doesn't compile with a specific version of a dependency. It works with older ones, it works with newer ones. So I wanted to publish a new version that explicitly forbids that version.

Unfortunately, it doesn't seem to be possible. While it's possible to list multiple requirements for version (eg both upper and lower bound), there's no way to exclude certain version. What I tried and didn't work is something like:

[dependencies]
my-dep = "~0.1.11, !0.1.20"

Would it make sense to support such blacklist?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by reviewing Cargo's existing version-requirement syntax and the issue's examples, then determine the intended exclusion semantics and how they should interact with existing bounds. Done means a decided syntax and behavior for excluding a specific dependency version, with existing requirements remaining understood and covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.