You are not logged in.

#1 2024-01-20 12:07:12

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 232

Automate removal of conflicting package

Is there a way that I can install a package that replaces another without being prompted to remove the package that is to be replaced?

This crops up a number of times, examples include replacing vim with gvim, iptables with iptables-nft, and so-on. The --noconfirm switch does not solve this because it just selects the default response, N, rather than allowing the replacement.

$ sudo pacman -S --noconfirm kubectx-bash
[sudo] password for myuser:
resolving dependencies...
looking for conflicting packages...
:: kubectx-bash and kubectx are in conflict. Remove kubectx? [y/N]
error: unresolvable package conflicts detected
error: failed to prepare transaction (conflicting dependencies)
:: kubectx-bash and kubectx are in conflict

I can use a workaround but I think it's a bit of a kludge:

yes y | sudo pacman -S kubectx-bash

I think this is a normally anticipated scenario becase packages are allowed to provide others, so such replacements are reasonable, expected and sometimes unavoidable (like when installing iptables-nft which replaces iptables that is part of base).

I need to be able to do this in an automated way, for example from an Ansible playbook. Being able to do this with community.general.pacman would be nice but I can use a command or script if necessary, like if the kludge above is the only way to do this.

Offline

#2 2024-01-20 14:14:41

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,621
Website

Re: Automate removal of conflicting package

I don't have an answer to your actual question, but some of your details are off.  When packages actually replace others (i.e., via "provides") then the default answer is Yes and noconfirm will work for all such cases.  The default answer only seems to be No for a conflicting packages that do not provide the existing one: they are not replacements, but genuinely different packages that happen to conflict.

(EDIT: I just checked one example and this may not be the case ... anymore(?).  I'm pretty sure this was the case previously).

Last edited by Trilby (2024-01-20 14:15:32)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#3 2024-01-22 20:27:39

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 232

Re: Automate removal of conflicting package

I think packages can be marked as conflcting other packages (like go-yq conflicts witl yq or gvim conflicts with vim), however there are use scenarios where one may want to automate the removal of the conflcting package anyway so that the package replacement can be applied automatically and non-interactively. I'll probably just use the kludge if there's nothing better but it seems to be this is a genuine use-case where a flag such as --replace-conflicting might be useful. Or perhaps be able to give --noconfirm=yes to accept all prompts with a yes answer. Don't know, just thinking aloud...

Offline

#4 2024-01-22 22:32:11

seth
Member
Registered: 2012-09-03
Posts: 52,317

Offline

Board footer

Powered by FluxBB