Pkg.jl icon indicating copy to clipboard operation
Pkg.jl copied to clipboard

`ctrl-c` during registry updates leads to corruption

Open ericphanson opened this issue 3 years ago • 10 comments

I didn't see any issue for this but let me know if it's a duplicate. (This is usually fixed fine by rming and adding the registry, but many users don't know that).

ericphanson avatar Jun 01 '21 18:06 ericphanson

During git clone then? Otherwise it is just a file move.

fredrikekre avatar Jun 01 '21 19:06 fredrikekre

When I've seen it on my machine, it might've been during git clone yeah. (I get very annoyed by Pkg server registry delays so I usually switch to the git version). I'm not sure about the other cases I've heard about.

ericphanson avatar Jun 03 '21 10:06 ericphanson

I'm not sure if there's much we can do about this when the registry is transferred via git: the git CLI program is likely to be ctrl-C resilient, but libgit2 is unlikely to be. Now that we do this by downloading a compressed tarball and reading it directly, this should be much better since we unconditionally do that everywhere.

StefanKarpinski avatar Jul 08 '21 11:07 StefanKarpinski

I'm not sure if there's much we can do about this

I was imagining a try-catch around the problematic libgit operations to try to safely handle interrupts or print a warning or something. But if we are moving off git and the new way doesn't have this problem then probably it's not worth it.

ericphanson avatar Jul 08 '21 12:07 ericphanson

But if we are moving off git and the new way doesn't have this problem then probably it's not worth it.

Well, the reason you are using git:

(I get very annoyed by Pkg server registry delays so I usually switch to the git version)

will still be there so it doesn't seem like anything with the registry being uncompressed or not will have an effect here.

KristofferC avatar Jul 08 '21 13:07 KristofferC

Yeah... was hoping that one could get solved too 😄. But if there is not much hope there and git will continue to be the path for active developers who want their new versions asap then maybe continuing to support/develop the git mode is the way to go.

ericphanson avatar Jul 08 '21 13:07 ericphanson

@josephsdavid just ran into this with our private registry (we don't have a package server), so I'll bump this :).

ericphanson avatar Jun 14 '22 20:06 ericphanson

@josephsdavid just ran into this with our private registry (we don't have a package server), so I'll bump this :).

This may be a problem exists between keyboard and chair scenario 😅😅 remains unclear!

josephsdavid avatar Jun 14 '22 22:06 josephsdavid

For git repos we clone it to a tmp directory:

https://github.com/JuliaLang/Pkg.jl/blob/423343402943074825392faa8b04a6d353204689/src/Registry/Registry.jl#L224

and then move it in place:

https://github.com/JuliaLang/Pkg.jl/blob/423343402943074825392faa8b04a6d353204689/src/Registry/Registry.jl#L250.

If the temp dir and the final destination is on different drives then I guess the move will have to copy things file by file and interrupting it could leave an incomplete registry. So perhaps the mv should be in a try-catch and have the directory removed if it fails?

KristofferC avatar Jun 15 '22 07:06 KristofferC

Sorry, apparently I assumed it was this issue too soon- @josephsdavid can probably say more but apparently it was an unrelated issue, something about some crazy interaction between git worktrees and Pkg, and not related to interrupts. (IMO it would be good to have a separate issue for that @josephsdavid but I know you already spent a few hours on this so idk if you have the time to try to reproduce what happened).

ericphanson avatar Jun 15 '22 18:06 ericphanson