Remove conflicts when --noconfirm is set
General overview
During operations, pacman
can ask questions to guide the user. This includes:
- provider selection,
- install confirmation, and
- conflict resolution.
For non-interactive scripts, pacman
provides the option --noconfirm
to let pacman choose sensible defaults and not ask the questions. The opposing option --confirm
reverses that behaviour.
The issue
Sometimes, the defaults set by pacman
aren't desired though, which leads to issues while still keeping the non-interactiveness.
As a very practical example, archlinux/devtools@b7893a2c wants conflicts to be resolved by replacement instead of failing. Essentially, instead of defaulting to no
, the question to remove the conflicting package needs to default to yes
.
While the introduction is more general, this issue is only concerned with the example at hand, i.e. removal of the existing package if it conflicts with a new one.
Solutions
There are 2 approaches I've considered:
- The default could be changed generally from a
noyes
question to ayesno
question. This might not be advisable in an interactive session and means a break in terms of compatibility. - A new option, (only?) valid in combination with
--noconfirm
, to switch the default fromno
toyes
. This might take the form ofpacman -S --noconfirm --remove-conflicting-pkgs
.
What do you think?
Examples for illustration
Current behaviour:
# pacman -S pipewire-jack
[...]
# pacman -S --noconfirm jack2
resolving dependencies...
looking for conflicting packages...
:: jack2 and pipewire-jack are in conflict (jack). Remove pipewire-jack? [y/N]
error: unresolvable package conflicts detected
error: failed to prepare transaction (conflicting dependencies)
:: jack2 and pipewire-jack are in conflict
New behaviour:
# pacman -S pipewire-jack
[...]
# pacman -S --noconfirm --remove-conflicting-pkgs jack2
resolving dependencies...
looking for conflicting packages...
:: jack2 and pipewire-jack are in conflict (jack). Remove pipewire-jack? [Y/n]
Packages (2) pipewire-jack-1:0.3.83-1 [removal] jack2-1.9.22-1
[...]