Allow update to proceed even if a file/dir in the old toolchain is missing - #5040
Allow update to proceed even if a file/dir in the old toolchain is missing#5040Walnut356 wants to merge 1 commit into
update to proceed even if a file/dir in the old toolchain is missing#5040Conversation
42a3d40 to
56351a6
Compare
|
@Walnut356 Hi, thanks for the patch! If I have understood the context correctly, you are trying to provide a band-aid solution here to #988 and #4400 (many thanks for providing the link to #1480, I'll merge those issues on my side). However, the underlying issue here is that rustup allows putting toolchains into a half-installed state and it will stay visible but any modifications to it might get stuck, which is exactly the kind of thing we would like to prevent from now on. A more comprehensive solution is being worked on and tracked by rust-lang/goals#736. As such, I would reject this patch as-is. Many thanks nonetheless for the investigation! |
|
@Walnut356 Please don't hesitate to let me know if you have further concerns or if you want to help with triaging/issue resolution etc :D |
While this might be an underlying issue, it's not the only one. I encountered this FWIW, in the context of debugger visualizers, it should be valid for users to overwrite our existing ones with their own (including ones that don't match our existing file structure). Since they are scripts loaded at debug-time by the debugger, it is expected that users can modify them when/however they want to. Modifying them in the toolchain install makes things significantly easier since most tools (e.g. CodeLLDB) already point there. Anecdotally, I pull mine from Regardless, I disagree that this is a bandaid. I don't think it makes any sense for |
|
@Walnut356 LLDB supports injecting debug scripts from any path, so you don't need to modify the one in the installation. See https://github.com/cmrschwarz/rust-prettifier-for-lldb for an example of how you would use this with LLDB CLI or CodeLLDB. If you are using other IDEs than VSCode, say Neovim, they basically also support VSCode's configuration format, so it remains quite portable. Otherwise, it looks like we are having a disagreement WRT rustup's fundamental assumptions here. Personally, I would argue that intentionally modifying the toolchain for e.g. custom debug scripts is not a supported use case, since rustup is assumed to have full control over all the files that it has installed (not linked toolchains which are designed to be immutable) and thus it's rustup's responsibility to ensure their integrity (admittedly, rustup has been historically doing a bad job here, but this is what we want to improve in the upcoming months). This assumption is also very important if we want to implement toolchain deduplication. |
|
FWIW, I've been the one primarily updating rust's debugger visualizers and the debug info test suite for the past year or so, so I'm not unaware of the alternatives. That said, I have to test on more than 1 debugger adapter and it's way easier to change 1 toolchain once than a bunch of tools every single time i need to test something. I understand that's not a "default usecase", or even a common one, but i still don't think this failure mode makes any kind of sense. Part of the issue is that When I say tools "point to" the toolchain installation, i mean they automatically import rust's scripts and (at best) you need to manually tell them not to (which isn't always possible, e.g. if the command is built into a pre-compiled debugger adapter binary). For example, if I want to prevent CodeLLDB from importing rust's visualizers (so that I can use my own), I would need to modify this file in my vscode installation of CodeLLDB. Or I would need to incorporate manually unloading all of the rust visualizers in my own visualizer scripts. There are instances of the visualizer scripts causing LLDB to segfault or read arbitrary amounts of ram (e.g. i've seen it try to read Regardless of all that though, as I said, I do not understand how this failure mode is useful. My understanding is that
I fail to see how a missing file impedes any of those operations in any meaningful way. If the problem is that At the absolute most, |
|
For sake of comparison, I think it makes a lot of sense to cancel |
|
@Walnut356 Thanks a lot for the extra context here, and my sincere apologies for the premature closing of your patch! I think I now have a better understanding of your situation. On the other hand, since rustup notes all files it has installed, of course this will cause a conflict, and it will feel very weird to ask the user to modify both the record of the files being installed and the actual files on disk... I definitely agree that the current failure mode is unacceptable if modifying the toolchain's contents is absolutely necessary like you have suggested already, where your proposed solution is pretty valid. That said, I may need some more time to evaluate how that will fit into our common understandings of what rustup should take care of while satisfying your particular needs. |
FWIW the original rationale of this failure mode is that rustup needs to backup everything it will be overwriting in case the whole transaction fails, and for that it has to know what exactly it has installed previously and if for some reason this record is inaccurate it will be considered an internal fault. However I believe this transaction model has serious design flaws. I'm not opposed to introducing a fix like this right now if there are no other alternatives, but since the whole system will be replaced in a later version, I'm afraid this expected user journey will break some invariants (meaning this solution might work for you right now but break again in a later iteration, which both of us don't want to see.) |
|
It's all good. My usecase is incredibly uncommon and definitely spacebar heating territory. I'm sure you'd be horrified to learn that on my other computer, my I'm not super attached to that workflow, especially as rust's tests have become more useful. My larger issue is I'm absolutely not familiar with rustup or filesystems, but i was somewhat surprised to eee that the behavior involved deleting anything in the first place. Would it make more sense to just rename the top level |
I agree that that seems like a useful invariant to maintain. |
@Walnut356 That is a fair point, fully content-addressable Rust toolchains (at least official ones) is actually something I'm aiming at, but the current semantics is far from it. So just for the sake of exploration, let's say your |
Hmm... I might be losing my mind 🫠 Maybe I have some config setting set or I'm forgetting how i'm running
But i checked the computer that i just updated and there isn't a Maybe before i was using And there's absolutely no way i would run such a hyper specific install ( |
@Walnut356 That is what I am suggesting: this can never happen today unless you have asked for them specifically. However maybe the ask wasn't explicit on your side because it's hidden in some |
|
@Walnut356 I gave another look at your original issue. A quick recap of what we have now: rustup only knows from the manifest files (the toolchain and component manifests respectively) what can be installed and what it has installed on the disk. Without any extra mechanisms that may be introduced in the future such as #3940, that is all rustup knows about a toolchain installation. I'd love to accept this PR if you think the below is acceptable in terms of general user journey:
|
| path: relpath, | ||
| } | ||
| .into()); | ||
| // If the file doesn't exist, that's fine, since we would just be deleting it anyway |
There was a problem hiding this comment.
IMHO we should keep the API shape (with component: &str). The actual error and this comment line can be converted to warn!() though, where component and path can still be useful.
Same thing for remove_dir() below.
|
☔ The latest upstream changes (possibly #5052) made this pull request unmergeable. Please resolve the merge conflicts. |
Resolves: #1480
If a file doesn't exist, the outcome is identical to deleting it (from the user's perspective), so it shouldn't prevent
rustup updatefrom proceeding.