Cargo fails to run when an *optional* dependency is missing
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
#!/usr/bin/env bash
set -e
cd /tmp
[ -d cargo-optional-deps ] && rm -rf cargo-optional-deps
cargo new cargo-optional-deps
cd cargo-optional-deps
cargo build
cat >> Cargo.toml <<EOF
optional_dep_does_not_exist = { version = "1.0", optional = true }
EOF
cargo build
Fails with
error: no matching package named
optional_dep_does_not_existfound (required bycargo-optional-deps)
I did not expect this because the dependency is not required as per http://doc.crates.io/manifest.html#the-features-section:
optional dependencies, which enhance a package, but are not required; and
I'm running into this behavior while integrating Cargo into a private build system that wants control over dependencies. As such, I need to elide optional dependencies by default in this system's dependency list.
I'm opening this issue to get some input on:
- Would ignoring missing optional dependencies for inactive features be a problem for Cargo?
- I tried to look through existing issues - has something like this been discussed before?
- An idea about resourcing/priority of the feature and how it fits into the roadmap for Cargo's integration with existing systems.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the shell reproduction from the issue to confirm Cargo's behavior when an inactive optional dependency cannot be found. Investigate Cargo's dependency resolution and feature handling, then determine whether missing optional dependencies should be ignored and what the resulting dependency list should contain.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100