Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow [replace] overrides to track versions of a replacement #2977

Closed
aidanhs opened this issue Aug 9, 2016 · 6 comments
Closed

Allow [replace] overrides to track versions of a replacement #2977

aidanhs opened this issue Aug 9, 2016 · 6 comments

Comments

@aidanhs
Copy link
Member

aidanhs commented Aug 9, 2016

This issue title is subideal, so I'll give an example.

Crate foo is 1.0.0. They don't really want to add a 5k loc build script to support people using a specific 15 year old version of solaris. Acme corp use this version of solaris and would really like to use crate foo. They would like to create a fork of foo and use it in their projects, and they'll handle tracking foo upstream and bumping acmefoo. The replacement line might look something like "foo" = { track = "acmefoo" } - any version of foo in the dependency tree will be swapped out for acmefoo.

Ecosystem divergence is prevented by making sure the upstream crate is always the source of truth of version numbers

  • if foo doesn't have a version X, there is no way for the acmefoo crate to be used via replace - version numbers are taken from crates.io for foo
  • as soon as a foo version X is released, acmefoo must also release X or risk build failures when cargo attempts to get acmefoo version X

Unresolved question: what happens if acmefoo ends up with a bug in their crate? How do they release a fix? Maybe this should remain an unresolved question to try and encourage these tracked replacements to be very thin.

This is not the same as #2649

@alexcrichton
Copy link
Member

cc @wycats, an interesting use case that doesn't quite match what [replace] does today.

@aidanhs how come though [replace] couldn't be used perhaps pointing to a git repo with tags for all the versions of the replaced crate that have been published? Is it just too onerous to update that version in Cargo.toml when you want to update?

@aidanhs
Copy link
Member Author

aidanhs commented Aug 16, 2016

It's both onerous and prone to human error - someone adds another crate depending on a different version of foo? Hope you remembered to add a replace line! cargo update? Better check the Cargo.lock to update all the replace lines! When you're used to Cargo magically getting things right, this isn't a great experience. Note that maintaining a tracked crate like acmefoo is also a lot of work, but the effort isn't duplicated across all consuming crates.

Just to add a concrete example of where this would be useful, see sfackler/rust-openssl#434. Not wanting to be on the hook for rushing out openssl releases is perfectly reasonable, but I'm willing to tolerate being a bit behind in my own projects. In general there are plenty of cases where an idea doesn't align with the intentions of the upstream crate but it's easy to maintain a fork.

Thinking about the unresolved question (bugfixes to tracked crates), I wonder if we could abuse prerelease notation - a track line would make Cargo look for the most recent prerelease for individual versions. E.g. say the dep tree has foo = "1.2.3" somewhere, if foo was made to 'track' acmefoo then Cargo would find all acmefoo prerelease versions, i.e. 1.2.3-*, order them according to semver and lock to the most recent one. This conceptually makes some sense - one can never be certain that you've achieved the desired feature parity, so it doesn't really make sense to have a release.

@alexcrichton
Copy link
Member

Note that for cases like native libraries this is what overriding build scripts was intended for, where you'd have your own precompiled version of OpenSSL for musl.

@aidanhs
Copy link
Member Author

aidanhs commented Aug 16, 2016

I have some thoughts on improvements to make that more useful which I'll think about, but it can't help if you don't have the library built (so you want to build it from scratch within a build script, like libz and libssh2, or distribute the openssl .a files).

@alexcrichton
Copy link
Member

Right yes the purpose is to override with precompiled artifacts, not part of the normal build process (hence the .cargo/config location)

@alexcrichton
Copy link
Member

I believe this has been "effectively added" in the sense that we've since added [patch] and are unlikely to change [replace], so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants