You are not logged in.

#1 2022-07-16 23:57:00

1.7xr
Member
Registered: 2021-02-21
Posts: 4

pacman -Rns $(pacman -Qttdq) asks to delete all packages one by one...

I've used the above command to clean orphaned packages for a long time, till today where I found an alternative command for it (in the Arch wiki, it has to do something with ~pacman -Rsu). Typed it and it deleted some unused packages (unused dependencies) but since then, if I try to type "sudo pacman -Rns $(pacman -Qttdq)", It asks to remove all packages (like it promotes to delete all packages installed explicitly, sorted by alphabet, a new package every time I run the command). and when I press "Ctrl-C" to kill the command it opens all apps, one by one, also sorted by alphabet. For example, it opens Ark, then Bleachbit when the former is closed, then ......
Any possible solution ?

Last edited by 1.7xr (2022-07-16 23:59:30)

Offline

#2 2022-07-17 00:17:59

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: pacman -Rns $(pacman -Qttdq) asks to delete all packages one by one...

Check the output of the command "pacman -Qttdq". There may be a package name in there that is interpreted as a separate command. To avoid this sort of expansion, it is recommended to pipe the output to pacman:

pacman -Qqdt | pacman -Rsn -

Note the "-" which tells pacman to read the names from stdin. I also omitted the extra "-t" because systematically removing optdeps is generally not desirable.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#3 2022-07-17 00:33:07

1.7xr
Member
Registered: 2021-02-21
Posts: 4

Re: pacman -Rns $(pacman -Qttdq) asks to delete all packages one by one...

pacman -Qttdq

shows a list of all installed packages and

pacman -Qqdt | pacman -Rsn -

promotes to delete them...
Is there a way to delete pacman database completely and rebuild it ? I've run

pacman -Syyu

couple of times and it didn't help.

Offline

#4 2022-07-17 01:31:11

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: pacman -Rns $(pacman -Qttdq) asks to delete all packages one by one...

The sync database is fully refreshed after "pacman -Syyu". The local database cannot be recreated once deleted so you should not do that.

Pacman is supposed to prompt you before removing packages unless you pass the --noconfirm option. However, that command should not run other commands nor try to delete everything that you have installed.
So, are the packages listed by "pacman -Qttdq" not orphans? If so, did you accidentally change the installation reason of all of your packages?
It is also unclear how that command could possibly lead to other commands being run as you described in your first post.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#5 2022-07-17 01:38:38

1.7xr
Member
Registered: 2021-02-21
Posts: 4

Re: pacman -Rns $(pacman -Qttdq) asks to delete all packages one by one...

did you accidentally change the installation reason of all of your packages?
Yeah I think that's the reason, because when I type "pacman -Qe" it only lists 4 packages, and all others are listed as orphaned packages...
Any way to fix this ?
Edit: The command that caused the problem is :

pacman -Qtdq | pacman -Rns -

Last edited by 1.7xr (2022-07-17 01:47:21)

Offline

#6 2022-07-17 03:22:20

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: pacman -Rns $(pacman -Qttdq) asks to delete all packages one by one...

1.7xr wrote:

Edit: The command that caused the problem is :

pacman -Qtdq | pacman -Rns -

There is no way that command could change the installation reason of your packages. The reason can only be changed with "pacman -S --asdeps" or "pacman -D --asdeps".

You can manually create a list of the explicitly installed packages, one per line, and then pass it to pacman -D to change the reason:

pacman -D --asexplicit - < pkgs.txt

You could start with the list of all installed packages and filter them

pacman -Qq > all_pkgs.txt

edit: Added missing "-" to command above.

Last edited by Xyne (2022-07-18 01:01:39)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#7 2022-07-17 22:25:18

1.7xr
Member
Registered: 2021-02-21
Posts: 4

Re: pacman -Rns $(pacman -Qttdq) asks to delete all packages one by one...

Thanks mate! I remember that the last time I've ran the clean command, there was nothing to clean. Therefore, any other packages are certainly explicitly installed.
Your command didn't work. So, I searched the forum and found this command:

sudo pacman -D --asexplicit $(awk '{print $1}'  input_file.txt)

and It fixed it!
Thanks for your time... The problem can be marked as Solved.

Offline

#8 2022-07-17 22:56:02

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: pacman -Rns $(pacman -Qttdq) asks to delete all packages one by one...

You can mark the thread yourself (edit your first post and add [SOLVED] to the title).

Offline

#9 2022-07-18 01:04:17

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: pacman -Rns $(pacman -Qttdq) asks to delete all packages one by one...

Sorry, my command was missing a "-". I've edited my previous post to fix it.

I'm glad that you've fixed it. You can edit the first post and prepend "[SOLVED]" to the subject.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

Board footer

Powered by FluxBB