Score:0

E: Unable to locate package php-7-v-podlinnike.pdf

tt flag

I tried to uninstall PHP but I got the following error instead. What does this error mean and how to solve it?

$ sudo apt-get remove --purge php*
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package php-7-v-podlinnike.pdf
E: Couldn't find any package by glob 'php-7-v-podlinnike.pdf'
E: Couldn't find any package by regex 'php-7-v-podlinnike.pdf'
cn flag
* is NOT a wildcard for apt. Why the need to remove it? It should not harm anything in your system :)
Raffa avatar
jp flag
@Rinzwind It's not safe to rely on, yes ... But, if a simulation is run using `*` ... e.g. `apt-get -s remove 'vlc*'` ... `apt` will state that it is using it as a globbing character an will print something like `Note, selecting 'vlc-plugin-qt' for glob 'vlc*'`.
Score:1
jp flag

It appears that the unquoted php* is expanded by your shell to a filename(php-7-v-podlinnike.pdf) that exists in your current working directory ... In which case, the expansion will happen before the package name/name pattern is passed to apt-get ... Therefore all apt-get will see in this case is php-7-v-podlinnike.pdf and not php* ... You can run set -x(to enable printing command debugging/execution) in your terminal then run your command to see that what is actually passed to apt-get looks like this:

apt-get remove --purge php-7-v-podlinnike.pdf

and not:

apt-get remove --purge php*

as you might think.

You can prevent that expansion by quoting it(i.e. either "php*" or 'php*') ... Note that single quotes '...' can be safer in this case as noted by @Thomas Ward.

Also, your assumption of apt-get using the globbing pattern to match any package starting with php in its name might not be always correct/safe ... apt-get seems to, sometimes, might handle that as a regular expression and not a globbing pattern ... As you see in your case apt-get tried both by glob and by regex:

E: Couldn't find any package by glob 'php-7-v-podlinnike.pdf'
E: Couldn't find any package by regex 'php-7-v-podlinnike.pdf'

So, you might want to use something like '^php.*' instead as a safer alternative.

I would, however, advice you to be very cautious when mass removing packages and carefully read the list of packages to be removed before answering yes to action/s suggested by apt-get ... See for example apt-get remove with wildcard removed way more than expected. why?.

Also, as a side note, if you exclude the --purge option, packages will still be removed but configuration files will be saved in case you decide to reinstall a certain package later so it will use those configuration files(so it behaves the same way it used to before you remove it) instead of starting from scratch.

You can also use the -s option to simulate the result of your apt-get command without actually removing any package like so:

apt-get -s remove 'php*'
ru flag
I would use single quotes because `*` sometimes is mishandled in double-quotes (anything in bash single quotes is processed verbatim without expansion/replacement)
Raffa avatar
jp flag
@ThomasWard It doesn't harm to single quote ... Bot isn't necessary either ... Only variables are expanded inside double quotes ... So unless `$` is used in the package name which shouldn't be used ... It is passed by the shell to `apt-get` in single qoutes anyway(*which can be observed if `set -x` command debugging is used*) ... However, earlier expansion of parameters by the shell might/will happen ... You got a point there so I will edit the answer :-)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.