-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Relax requirement that [replace] overrides have the same version number #2649
Comments
IMO you shouldn't have included a version number increment, that would have solved everything? |
Yes, but that’s not the point. As a maintainer, if someone sending me a PR expects the change to published on crates.io soon after merging, I like if they include the version number increment in the PR. That’s one fewer step for me to do (if the change is small I might take a couple minutes to review/merge/publish it while I’m in the middle of doing something else), and I’m less likely to forget. Even if it’s not a workflow you prefer personally as a maintainer, I don’t think there’s anything wrong with it or a good reason for Cargo to make it more difficult. |
That is the point. Including a version bump is an antipattern, that's up to the maintainer (which you can of course request in comments) |
I disagree, but at this point we’re going in circles. But even if it is an antipattern, it’s not a "you’re absolutely gonna shoot yourself in the foot" mistake. I don’t think Cargo should be that opinionated about workflows. |
For what it’s worth, in servo/* repositories the maintainers never push to master. Anyone (including maintainers) who wants to land any change makes a PR, has it reviewed by someone else who then tells homu to send it to CI and land it if tests pass. Waiting for Travis-CI to schedule a build and run tests takes a few to many minutes. When a PR has changes we know we want on crates.io, if we have to wait for it land to make another PR and do this whole dance all over again just to increment the version number, that’s a lot of overhead. |
Fun fact: @nikomatsakis himself bumps his own projects to N+1 the moment he releases N. This means his projects cannot be replaced with master. This |
(I'm not really sure what's being discussed in this issue, but I certainly wouldn't take my usage of cargo to be "best practice".) |
What exactly do you expect us to do when our bumps are that involved? Do twice as many PRs in two batches, the first without the bumps and the second with just them? That doesn't scale, whatever were your comments on #2385. |
I've been talking a lot with @SimonSapin, @nox, @wycats, and @alexcrichton about this issue. I'm not going to rehash everything here, but I wanted to float a proposal I've been thinking about and have talked to @wycats and @alexcrichton about in some detail, and they are basically on board with. If this looks like it will meet everyone's needs, I'll write up an RFC. The basic idea was inspired by @nox's idea of a "staging index": basically, provide a way to layer a "pre-publication" version of a crate on top of an existing source like crates.io. The key point is that the pre-publication version works with Cargo's dependency resolution as if it had been published to crates.io. But the pre-publication version can come from a different location, such as a git repository. Let's take the xml-rs example from this issue; let's say it's currently at version 0.3.1 on crates.io. Here's what the workflow would look like:
The idea here is that you set up the version dependencies of your Cargo.toml as they should be once all publication has taken placee. While you're working prior to publication, you are getting the new version from a git repository. Cargo, however, will resolve dependencies as if that new version had been published. This is crucially different from
Stepping back, this If you have a crate in Why is this better than just letting More generally, in terms of trying to model an "atomic transaction" across repos, working with the eventual published version and Cargo's usual resolution gives a much more principled and clear story about what's going on than you get with One of the big fears about letting Even if we do add something like @SimonSapin, @nox, @larsbergstrom: what do you think? |
@aturon This looks great! Thank you for putting this together. I think that a key insight is that the way Would (Unimportant correction: in your workflow description, "Make PR for Servo" comes after "Do integration testing". But running all Servo tests on a laptop tends to take a very long time so we usually do that on CI servers, which involves opening a PR earlier in this workflow.) |
@SimonSapin it definitely doesn't need to be in every crate. I'm not sure if we'd need to force it at crate root, or whether it could make sense to accumulate prepublications anywhere they appear. |
Sounds good to me, thanks for the writeup @aturon! In terms of the nitty-gritty details we've often wanted the ability to augment sources in
I have a hunch that this sort of [prepublish] would want to integrate with this or otherwise be along these lines. All that basically to say that literally as written here: [prepublish]
foo = { git = '..' } I think may not quite suffice because there's an implicit registry that's being modified, the crates.io registry. It may work by saying that this uses the "default" registry and we end up with the same syntax, but something to be considered at least (minor details) |
Some discussion of
In particular, there’s a proposal to systematically add a |
@SimonSapin I believe the preferred solution there is what's on the tin of https://bugzilla.mozilla.org/show_bug.cgi?id=1342815, no? That is, the real problem is that it's not trivial to fork code locally to do local edits when testing things out, it's a few steps. Beyond that though it doesn't sound related to this particular issue at all? |
@alexcrichton I think @SimonSapin was just giving us a heads up; this issue is where we've been logging the overall issues around I do suspect that using |
Yes, I wanted to point to these threads to show other pain points around (Though I also think that |
This would be a nice feature to have. I've just come across a problem where changes to nightly have broken old versions of the cocoa crate, such as One solution would be to fork all the dependencies that I rely on that specify a cocoa version and then change their |
Closing now that |
Top-level overrides with
[replace]
as implemented in #2385 require that the replacement has the exact same version number in itsCargo.toml
as the package being replaced. As others have discussed in the PR I think this restriction gets in the way more than it helps.Here is a workflow I just had. This happens more often than not when I use
[replace]
.[replace]
override, which doesn’t work because versions don’t match. I have to revert the version number locally. If I want some else to use my override, I need to push a second branch of the dependency with the same changes but without the version number increment.Maybe the requirement could be that the replacement’s version is SemVer-compatible with the thing being replaced, instead of exactly the same?
The text was updated successfully, but these errors were encountered: