You are not logged in.

#1 2020-06-16 20:13:18

zuntik
Member
Registered: 2017-08-11
Posts: 46

[Solved] Reinstall all packages with missing files

On my last update I was getting that conflicting files error "<filename> exists in filesystem", these files were obviously put there by a package but to solve this error I followed this suggestion and deleted them. However, there were lots of files listed. Most belonged under "/usr/lib/ruby/gems/2.7.0/gems/" directory so I was a bit reckless and deleted all of the contents of that dir without thinking. And now, with another update, I'm getting loads of "(No such file or directory)" issues by the command "pacman -Qk". This command provides the name of the packages whose files are missing so I've been installing them manually but there are plenty more to go... Some of these files belong to the AUR so I'm using an aur helper (yay, to be exact).

tl;dr
How do I reinstall all packages that have missing files?
And, in the future, how can I auto delete all files that cause conflict and do not have an owner?

Thank You

Last edited by zuntik (2020-06-17 19:11:38)

Offline

#2 2020-06-16 20:41:24

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,791

Re: [Solved] Reinstall all packages with missing files

these files were "obviously" put there by a package

https://wiki.archlinux.org/index.php/Ru … ing_pacman

How do I reinstall all packages that have missing files?

LC_ALL=C pacman -Qk 2>&1 | grep -E ', [1-9][0-9]* missing files' | cut -d':' -f1

will print a list of "damaged" packages that you can review, edit and feed into pacman -S or yay

how can I auto delete all files that cause conflict and do not have an owner?

man pacman wrote:

       --overwrite <glob>
           Bypass file conflict checks and overwrite conflicting files. If the package that is about to be installed contains files that are already installed and match glob,
           this option will cause all those files to be overwritten. Using --overwrite will not allow overwriting a directory with a file or installing packages with
           conflicting files and directories. Multiple patterns can be specified by separating them with a comma. May be specified multiple times. Patterns can be negated,
           such that files matching them will not be overwritten, by prefixing them with an exclamation mark. Subsequent matches will override previous ones. A leading
           literal exclamation mark or backslash needs to be escaped.

Offline

#3 2020-06-16 21:24:03

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

Re: [Solved] Reinstall all packages with missing files

Or just `sudo pacman -Qknq | cut -d' ' -f 1` to get the list of packages.  If you intend to review it, piping it through `sort -u` may also help if there are a lot of missing files.  But I'd just pipe it to pacman anyways, there's no harm in reinstalling a package if there was some odd false positive:

sudo pacman -Qknq | cut -d' ' -f 1 | sudo pacman -S -

I also included the 'n' for the first pacman to get just repo packages.  You could run it again with 'm' in place of 'm' and pipe the final output to your aur helper instead of pacman (if it can take lists on stdin).


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

Offline

#4 2020-06-16 21:30:51

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,791

Re: [Solved] Reinstall all packages with missing files

pacman -Qknq | cut -d" " -f1 | sort | uniq

The uncondensed list can grow quite long (eg. if you NoExtract locales ;-)

Offline

#5 2020-06-16 21:41:27

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

Re: [Solved] Reinstall all packages with missing files

sort | uniq => sort -u

But I have locales and man page translations in NoExtract, but these are not included in the Qk output.


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

Offline

#6 2020-06-16 22:35:24

zuntik
Member
Registered: 2017-08-11
Posts: 46

Re: [Solved] Reinstall all packages with missing files

Thank you seth and Tribly!
Looks like seth's first answer did the trick!

Offline

#7 2020-06-17 02:57:24

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [Solved] Reinstall all packages with missing files

Trilby wrote:

sort | uniq => sort -u

But I have locales and man page translations in NoExtract, but these are not included in the Qk output.

Having it in NoExtract prevents the warning, because it's expected to not exist. On the other hand, if you install something with NoExtract rules, then later remove those rules, it can indeed generate rather a lot of warnings.

As for the original topic, let's paint the bikeshed a different color and use a dedicated, non-default alpm tool:

$ sudo pacman -S pacutils
$ paccheck --quiet --files
i-am-a-broken-package: '/path/to/file' missing file
$ paccheck --list-broken --files
i-am-a-broken-package

No sorting, no uniq'ing, no redirecting stderr to stdout, no grep or cut.

--files only reports packages with missing files, there is a separate filter --file-properties for reporting permissions, file sizes, modification times, etc.

Of course, it could be done with just pacman alone, but where's the fun in that? wink


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB