Phantom dependencies

Because the publishers haven't seen any necessary reason to do so. Just because there is sufficient justification does not necessarily make doing so necessary. It also doesn't cover the entire 0.1 line either, anyway.

:grimacing:

I honestly thought crates had forbidden = "0" as well...

The point about lockfiles + time leading to the same result is the more important part of the argument, anyway.

Where "upgrade some of the dependencies" includes "adding a new dependency". Scenario:

# downstream
[dependencies]
serde = "1.0.100" # lockfile with this version, everything works

# time passes...

# yourlib
[dependencies]
serde = "1" # but you use features added after 1.0.100

# time passes ...

# downstream
[dependencies]
serde = "1.0.100" # lockfile still has this version
yourlib = "1" # oops, now yourlib is trying to use a too-old version of serde

But as you yourself said, people with a lockfile have a working configuration. The point of testing on minimal-versions is that when they add a dependency on your crate, it also results in increasing the version of the crates you use to the versions you need.

[patch] already works like this. The point of [phantom-dependencies] being separate is that it's inheritable by downstream users of your library, unlike [patch] which isn't, by design.

It does help in one measurable way: minimal-versions correctness. And my underlying point is that minimal-versions correctness isn't only about using minimal version resolution, it's also about normal application of time resulting in having old library versions in use. Yes, crate authors making mistakes happens, but the point is to have some attempt at locally communicating necessary versions.

As to your point, it's impossible to prove that cargo add will never result in a nonworking dependency tree. But that doesn't mean we should ignore iterative steps towards making it better, even if only partially.

The goal of [phantom-dependencies] is to

  • Allow -Zminimal-versions version resolution work a reasonable amount of the time when asking for recent dependencies
  • Thus making it reasonable to stabilize --minimal-versions version resolution
  • Thus making it easier to ask crate authors to be minimal-versions correct
  • Thus removing the need to use [phantom-dependencies].

People can and do introduce direct dependency edges to get the desired effect here. [phantom-dependencies], I hope, is strictly better than status quo.

Binaries already have the mechanism to do so: the lockfile. Libraries have no mechanism to even try.

1 Like