# Optional dependencies with same name

**URL:** <https://internals.rust-lang.org/t/optional-dependencies-with-same-name/8728>\
**Category:** cargo\
**Created:** [October 30, 2018, 7:51am UTC](https://internals.rust-lang.org/t/optional-dependencies-with-same-name/8728 "2018-10-30T07:51:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ignatenkobrain](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ignatenkobrain/32/3140_2.png) [@ignatenkobrain](https://internals.rust-lang.org/u/ignatenkobrain)\
**Post date:** [October 30, 2018, 7:51am UTC](https://internals.rust-lang.org/t/optional-dependencies-with-same-name/8728/1 "2018-10-30T07:51:40Z")

</div>

Imagine that you have something like:

```rust
[dependencies.clap]
version = "2"
optional = true

[build-dependencies.clap]
version = "2"
default-features = false
optional = true

```

Then you reference `clap` dependency from one of your features, which one would be referenced? Both?

P.S. this is not entirely theoretical case, see [https://pagure.io/fedora-rust/rust2rpm/pull-request/60#comment-67442](https://pagure.io/fedora-rust/rust2rpm/pull-request/60#comment-67442)

---

<div class="post-metadata">

**Author:** ![dtolnay](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/dtolnay/32/1447_2.png) [@dtolnay](https://internals.rust-lang.org/u/dtolnay)\
**Post date:** [October 30, 2018, 9:28am UTC](https://internals.rust-lang.org/t/optional-dependencies-with-same-name/8728/2 "2018-10-30T09:28:05Z")

</div>

Features are currently conflated across dependencies / dev-dependencies / build-dependencies. There are a few issues about this in the Cargo issue tracker – see [rust-lang/cargo#4361](https://github.com/rust-lang/cargo/issues/4361), [rust-lang/cargo#4664](https://github.com/rust-lang/cargo/issues/4664), [rust-lang/cargo#5730](https://github.com/rust-lang/cargo/issues/5730). So:

```rust
[features]
x = ["clap/..."]

```

would affect both.

This may change in the future.

---

<div class="post-metadata">

**Author:** ![ignatenkobrain](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ignatenkobrain/32/3140_2.png) [@ignatenkobrain](https://internals.rust-lang.org/u/ignatenkobrain)\
**Post date:** [October 30, 2018, 10:02am UTC](https://internals.rust-lang.org/t/optional-dependencies-with-same-name/8728/3 "2018-10-30T10:02:02Z")

</div>

IIUC, that technically it is merged, Right?

So if one has default-features=false and other doesn’t, cargo will always make sure that `clap` always have default-features enabled. Right?

---

<div class="post-metadata">

**Author:** ![dtolnay](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/dtolnay/32/1447_2.png) [@dtolnay](https://internals.rust-lang.org/u/dtolnay)\
**Post date:** [October 30, 2018, 4:23pm UTC](https://internals.rust-lang.org/t/optional-dependencies-with-same-name/8728/4 "2018-10-30T16:23:25Z")

</div>

You could try it to make sure, but yes that is my understanding.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:31am UTC](https://internals.rust-lang.org/t/optional-dependencies-with-same-name/8728/5 "2019-03-25T08:31:04Z")

</div>

Closed on March 25, 2019, 8:31am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
