You are not logged in.

#1 2015-09-09 10:14:04

pMay
Member
Registered: 2012-07-21
Posts: 4
Website

Question or problem with optional dependencies and pacman

Hello,
I have a question or problem with optional dependencies and pacman that I would like to discuss here.

Given:
- I explicitly install package A (that depends on package B that depends on package C)
- later I install Package X that has an optional dependency to package C

Then I remove (pacman -Rs A) package A.
This will also remove package C (because it does not have a direct dependency to A or B).

This is bad cause I might still need package C for package X - and now it is removed.

I have to admit that pacman will give a "hint" but wouldn't it be nice when there would be an additional option
to the pacman remove command to not remove optinal dependencies?

I think it would be very easy to implement cause pacman knows it and gives a hint...
Maybe something like "pacman -Rso A"?

What do you think?
Do I have an error in reasoning?

Thanks!

Edit: Changed -Rss to -Rso cause -Rss is already in use.

Last edited by pMay (2015-09-09 10:42:09)


Visit my Bliki on eniak.de

Offline

#2 2015-09-09 10:45:50

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Question or problem with optional dependencies and pacman

Your proposal is all or nothing? In your example you only have one optional dependency, but what if you have more and you want to keep some and remove others? You'd probably want either an interactive selection or more fine-grained control through command-line options.

With the current state of things: if you want package C as an optional dependency for X, you can mark it as explicitly installed (you would probably explicitly install it anyway if you didn't have it already as a result of previously installing package A). Then -s will not remove it, but -ss will.

Offline

#3 2015-09-09 11:38:25

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

Re: Question or problem with optional dependencies and pacman

pacman -R <pkgA> && pacman -R $(pacman -Qdtq)

This will remove pkgA but none of it's dependencies, then it will clean up by removing any packages that were installed as dependencies and are not required (or optionally required) by any other package.  You can easily make this into a shell function, or the second half into an alias.

But as Raynman rightly points out, this is still "all or nothing" - my sequence just gives you a way to remove a package and it's dependencies while keeping *all* of the dependencies that are optional for other packages (while -Rs gives you the 'none' option).  No command could read your mind to know which optional dependencies you really wanted to keep.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB