-
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
Add a new update-registry subcommand for use by scripts and third-party tools #5961
Conversation
…ty tools Scripts and third-party tools often need to update the registry, and they resort to invoking other cargo commands such as `search` to do so, which can and does potentially break when cargo changes the semantics of those commands. Add a dedicated command to update the registry instead.
(rust_highfive has picked a reviewer for you, use r? to override) |
This fixes #3377, as well as multiple requests that have arisen since then. |
This looks perfect for permanently fixing |
If you move "fixes #3377" to the PR description it'll close the issue on merge. |
@dwijnand I'm aware, but every time I've done that it also seems to generate half a dozen extra mails as those commits move through various branches and trees. |
I avoid them in commits message to avoid the spam, putting them only in PR descriptions. But looks like bors uses the PR description as the commit message, which can generate spam on multiple test runs (e.g for flaky tests or whatnot). |
@dwijnand Yeah, that's the problem I've run into. If you understand the problem a bit better, perhaps you could help report an issue on bors about it? (In any case, this is off-topic for this PR.) |
Crater needs this as well. |
I would personally prefer to land this as a nightly-only subcommand or somehow land it as unstable to start off with. I still feel unease that our story around this isn't well formed yet and am hesistant to expose some low level utilities which look tantalizingly like they may solve problems and end up being the wrong tool for the job. In any case I wouldn't be comfortable landing this on stable yet and would prefer some sort of unstable feature gate, but unfortunately we don't have an existing method to gate entire subcommands so a new strategy would need to be devised. |
Edit: Sorry for the inappropriate aggressive tone and the factually inaccurate assertions. Well if we want to add things as unstable then #5621 (comment) should not have made serch run against an out of date registry without an unstable flag opting into that behaviour. In fact we already have a unstable flag to ask cargo commands to not update the index, so why did serch change? |
I'm a little confused about this. Doesn't |
Ah that makes sense. Sorry for how strongly worded my last comment was. |
Yes |
@alexcrichton People have been counting on |
Crater is a special case, but why is there a reliance on updating the registry? Why would we consider it a breaking change to make I don't personally understand the need for updating the registry. |
@alexcrichton People building third-party commands or scripts atop Cargo need a way to update the registry before accessing it. (Projects that link to the Cargo crate can do so directly via its API, but not all third-party commands link to the Cargo crate.) I'm not suggesting that |
Because
Because, for all intents and purposes, it's (a) the consensus way of doing it (without linking to Tbph, this whole thing just feels like a big ole middle finger to maintainers – break a documented behaviour, thereby breaking dependent crates (for a small portion of users, admittedly), don't bump major, release the whole thing into nightly so it rolls out to everyone and stabilises in a couple weeks, refuse to consider a fix that will prevent it from breaking dependent crates for everyone. But hey, whatever, right? |
@nabijaczleweli, I don't think anyone's interests would be well-served here by making this discussion more heated. Nobody here is trying to break people; there's no malice here. A well-intentioned change went into the |
We discussed this at length in the @rust-lang/cargo meeting. There was some concern that adding an That said, there's a short-term need to address this now-missing functionality, which was available in stable and should continue to be in some form. One proposal in the meeting was to use Another proposal was to split this out into a separate crate that implements the equivalent functionality to update the registry. This would let people implement this without depending on the EDIT: There's also the approach taken by https://crates.io/crates/crates-index . We didn't settle on a consensus solution for this. The one conclusion from the meeting was to bring the discussion back to this issue, mention the above alternatives, and invite further comment. |
This is the approach currently used by Crater and is pretty much zero effort.
This would take a little effort, but not much, since it is only really doing a |
@nrc Creating that crate would take rather more effort than this PR, since it would duplicate a chunk of Cargo logic. (Leaving aside the issue of not wanting to duplicate that.) |
On Wed, Sep 05, 2018 at 03:54:47PM -0700, Nick Cameron wrote:
> One proposal in the meeting was to use cargo install instead of cargo search
This is the approach currently used by Crater and is pretty much zero effort.
I just checked, and the approach used in crater uses `cargo install lazy_static`, ignores any error (as the command *always* errors because `lazy_static` has no binaries to install), and suppresses all output (including progress output and error messages). That's a noticeably worse user experience.
|
For clarity: anything outside of "break the ability to distinguish errors in the registry update process"? |
@dwijnand Yes, it also suppresses progress output. |
If I understood correctly from the meeting, it would only need to |
Are there comments from those who desired this feature that we could hear from? Right now the discussion after our in-person meeting it basically just reiterating everything that was said in the meeting. This is good for having things on record, but not so great for reaching a conclusion unfortunately! FWIW I can list out the downsides to landing this PR as-is from my point of view, which will reiterate some of what's been said already:
A short term solution, already mentioned, is All in all I see a short term solution that while not a 100% match works well enough (we do not want anyone to be using cargo's index checkout anyway) and a long term solution also exists and largely just requires someone to put in the effort to make it happen. |
How viable is the option of just subsuming |
It's possible yeah but it's in the realm of "not trivial to do" as it likely requires an RFC |
As previously mentioned by @Eh2406 on Discord, the only thing one really need replicate is Thanks, Alex! 💜 |
Ok thanks for the info @nabijaczleweli! @joshtriplett would you still like to merge this PR in light of that information? |
@nabijaczleweli If that works for you, then that's fine. I'd certainly like to have that wrapped in a crate. (I'd also suggest that we update the checked-out version, except it seems that cargo hasn't updated that in a year...) |
@nabijaczleweli If you do end up spinning a exterior Also there is crates/crates-index that is almost what @alexcrichton described as the "ideal" solution. It is also not officially supported, but used by crater. Maybe with some love this could be made two work. In the distant future I'd love to see cargo spinning out the parts dealing with the registry into a separate crate with a fairly stable API, (or growing one of the above mentioned into it.) and have cargo use it. But that is going to be work, and I am not volunteering to leed it at this time. :-P |
@alexcrichton I, personally, am pro-close on this now. @joshtriplett Yeah, that seems to be the superiour solution in the long run, cheers for putting in this amount of work&time into it. @Eh2406 Will do, and thanks for that link! |
…which has stopped supporting this Does, effectively, a git fetch https://github.com/rust-lang/crates.io-index \ refs/heads/master:refs/remotes/origin/master like the original code: https://github.com/rust-lang/cargo/blob/1ee1ef0ea7ab47d657ca675e3b1bd2fcd68b5aab/src/cargo/sources/registry/remote.rs#L204 Big thanks to @Eh2406 for the original implementation, @joshtriplett for help and bastioning, and @alexcrichton for putting up with me. Closes #93 Ref: rust-lang/cargo#3377 Ref: rust-lang/cargo#5961
I'm going to close this as it's been quiet for quite some time and I believe the urgent issue was fixed |
Scripts and third-party tools often need to update the registry, and
they resort to invoking other cargo commands such as
search
to do so,which can and does potentially break when cargo changes the semantics of
those commands.
Add a dedicated command to update the registry instead.