rust-lang / rust-lang/cargo

Allow dependencies that only apply to specific cargo targets (bin, example, etc.)

Open
#1,982 84 comments 458 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

View all comments

Past RFCs

  • rust-lang/rfcs#2887
  • rust-lang/rfcs#3020
  • rust-lang/rfcs#3374

Related requests

  • rust-lang/cargo#4663

Use case: I have a library that also produces an executable. The executable needs env_logger in order to be able to log, the library shouldn't carry that dependency though, as it pulls in all sorts of crates (e.g. regex (?)).

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

Start by reading the linked RFCs and related issue rust-lang/cargo#4663 to understand the proposed target-specific dependency behavior and existing decisions. Done means Cargo can express dependencies used only by binaries, examples, or other specific targets without adding them to the library's dependency set.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.