Skip to content

feat(pm): halt and ask instead of aborting when a strap fails - #301

Closed
sernik77 wants to merge 4 commits into
h8d13:masterfrom
sernik77:pacstrap-error-recovery
Closed

sernik77 wants to merge 4 commits into
h8d13:masterfrom
sernik77:pacstrap-error-recovery

Conversation

@sernik77

@sernik77 sernik77 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Right now one broken package during pacstrap kills the whole install. You've
partitioned, picked everything, waited for the downloads, and then a single
conflict sends you back 5 minutes. This PR makes archinstoo let you choose.

Port of archlinux/archinstall#4870, adapted to how archinstoo already works.

  • pacman output is classified (conflict, missing target, file conflict,
    unsatisfiable dep) and you get fixes that fit: keep one side, drop, rename,
    overwrite, retry. Plus always: drop to a shell and resume, or exit.
  • Your keyring / pacman.conf resets stay: each runs once, automatically,
    before anything is asked. Only the blind "re-try download? (Y/n)" dead end
    is replaced.
  • --silent still stops instead of guessing, and interactive prompts just
    wait (no timeout picking for you).
  • No retry loops: it only retries if the package list actually changed.
  • Parses err.worker_log, not str(err). The latter is cut to 500 chars and
    often loses the line naming the conflict.
  • Choosing "Exit" doesn't print the bug report banner. Your selections were
    already saved before the install, so the next run offers to resume them.
  • Anything skipped gets listed again before the final verdict.
  • Host-to-target keeps pacman -S, with a hint that fits it.

Code: lib/pm/errors.py (pure parser, tested on recorded pacman output),
lib/pm/recovery.py (generic prompt), wired into Pacman.strap(). Tests in
test_pm_errors.py / test_pm_recovery.py; pytest and the full pre-commit
(ruff, mypy, pylint, lint-imports) pass.

In action

Both screenshots are from the archlinux/archinstall#4870 run. archinstoo shows the
same prompts, minus the "or wait 60s" fallback, since here they just wait.

jack2 + pipewire-jack in Additional packages: keep either side, drop
both, or the usual shell/exit. Keeping one also lets pacman replace the other
when an earlier step already installed it:
image

After a failed manual fix in the shell, the same failure shows up again, so
it now offers to skip the remaining packages and carry on:
image

Why: I kept hitting the jack2 / pipewire-jack conflict myself, and losing
a whole install over one package felt wrong. So I spent a few hours of spare
time, doing my part in making Arch a slightly better place :)

AI disclosure: the idea and design are mine; Claude Opus 5.5 wrote the code,
the tests and the first draft of this text. I tested it on archinstall in a
VM, and on an archinstoo ISO in a VM; Host-2-Target is still to do before I
mark this ready. I can explain any part of it.

sernik77 and others added 2 commits November 9, 2026 20:08
One conflicting package used to end the whole install: Pacman.ask() tried
its keyring/pacman.conf resets, offered a blind "re-try download?" and then
raised. Port of archlinux/archinstall#4870, adapted to archinstoo.

- pm/errors.py classifies pacman output (conflict, missing target, file
  conflict, unsatisfiable dependency, unknown). No I/O, tested against
  recorded output. It reads err.worker_log, since str(err) keeps only the
  last 500 characters and often loses the line naming the conflict.
- pm/recovery.py is the prompt: the caller's choices plus "resolve in a
  shell" and "exit", which are always there.
- Pacman.strap() keeps the keyring and pacman.conf resets: each runs once,
  before anything is asked. Then the prompt offers what can change the
  outcome: keep one side of a conflict, drop, rename, overwrite, retry.
- A retry only happens when the package list changed, and the same failure
  twice in a row stops offering the same way out, so no loops.
- --silent and a closed stdin stop the install instead of guessing, as
  before. Interactive prompts wait: no timeout picks anything.
- Choosing "Exit" is reported without the bug report banner; the selections
  were saved before the install, so the next run offers to resume them.
- Skipped packages are listed again before the final verdict.
- Host-to-target keeps pacman -S, with a hint that fits it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keys pressed while pacstrap was running (an Enter or two while waiting)
sat in the terminal buffer and answered the prompt unseen, and every wrong
answer redrew the whole block, stacking copies of the choices on screen.

Flush pending input before each question, and ask again on one line
instead of re-rendering; an empty line just asks again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sernik77
sernik77 force-pushed the pacstrap-error-recovery branch from dfd94b8 to 481d37c Compare November 9, 2026 19:08
sernik77 and others added 2 commits November 9, 2026 20:15
Current pacman names both sides of a conflict as name-pkgver-pkgrel
('pipewire-jack-1:1.6.10-1'). Taken verbatim, neither matched the request
list, so a conflict between two requested packages read as one between
dependencies and only shell/exit were offered. Cut the version, but only
when it looks like one, so names like dotnet-runtime-8.0 stay whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the side the user chose to drop had already been installed by an
earlier step, dropping it from the request changed nothing: pacman asked
"Remove pipewire-jack? [y/N]", --noconfirm answered no, and the retry
failed the same way. After an explicit keep choice, retry with --ask=4,
which answers exactly that question with yes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sernik77
sernik77 marked this pull request as ready for review November 9, 2026 20:02
@sernik77
sernik77 requested a review from h8d13 as a code owner November 9, 2026 20:02
@h8d13

h8d13 commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution !

I actually really like the idea. But the idea is a lot of different things together.

  1. Conflict handling

This sounds like a packaging issue (perhaps upstream-able)? Which combination caused this conflict?

  1. Instead of hard failing giving a way into a shell, skip or exit.

This is great, I really like this part. I think if you can move just this part to a separate PR I'd be really happy to take this idea. The more minimal the easier to test and review :)

@h8d13

h8d13 commented Nov 10, 2026

Copy link
Copy Markdown
Owner

I extracted a minimal patch from some of your changes :) Let me know what you think. ^^

For the more thorough error handling about conflicts and such, I'm not sure they would actually happen in practice with how archinstoo orders it's steps.

@h8d13

h8d13 commented Nov 10, 2026

Copy link
Copy Markdown
Owner

I'll close this for now, if you ever submit smaller patches I'll gladly review them more in depth

@h8d13 h8d13 closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants