Skip to content

Killing Emacs while straight.el is cloning and buildng packages can leave things in a bad state? #1134

@ntc2

Description

@ntc2

What's wrong

I'm in the process of porting my whole config to use-package+straight.el, with a focus on reproducibility (I had gotten into some weird state using use-package+package.el before, and want to avoid that). My test is to reinstall all the packages in my config in a sandbox, and this takes a long time. At one point I killed Emacs (Ctrl-C in the terminal I started Emacs from) while straight.el was installing packages, and I think it left things in a bad state: after that I was getting errors about "couldn't load package " (or similar, I don't remember the exact wording), and was eventually able to solve the problem by running M-x straight-pull-package on the failing package and confirming that I wanted to clean up its repo which was in a "dirty" state.

Directions to reproduce

Unfortunately, I don't have an easy way to reproduce this, as it must depend on exactly when you press Ctrl-C. So, this is not a very good bug report, and feel free to close it. In fact, I'm not even 100% sure that me killing Emacs with Ctrl-C was the source of the problem. However, my hope is that the maintainers might know if such a possibility of ending up in a bad state exists, and if so add a fix that prevents it, since it seems useful to be able to abort and restart a long install.

Searching through the existing issues, I found an issue where a user got confused that their package didn't get updated automatically when they changed the recipe, and the maintainers explained that this was because there's a simple check to see if the package's repo is already checked out, in which case nothing is done automatically (manually running something like straight-pull-package is needed, as in my case, but my case was more confusing, since I hadn't changed any recipe): #166 (comment) .

So, I'm wondering if this same check is to blame here: the repo exists, but is not fully cloned, but straight.el is assuming it was fully cloned. The fix could be to wrap calls to git pull (or whatever) in some kind of temporary "mark repo as dirty" state. E.g. something like (pseudo code):

touch <repo>.is-dirty
# If Emacs gets killed while `git pull` is running, 
# the `rm <repo>.is-dirty` will never happen.
git pull <repo>
rm <repo>.is-dirty

and then modify the startup check for the existence of <repo> to also check for the existence of <repo>.is-dirty file, and if so act as tho <repo> didn't exist.

Version information

  • Emacs version: 28.1
  • Operating system: Ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions