Why does `zypper se --provides --match-exact` not operate as I expect?

rokejulianlockhart@localhost:~> zypper se --provides --match-exact cnf
Loading repository data...
Reading installed packages...
No matching items found.
rokejulianlockhart@localhost:~> cnf krita
The program 'krita' can be found in following packages:
  * krita [ path: /usr/bin/krita, repository: zypp (openSUSE-20230123-0) ]
  * krita [ path: /usr/bin/krita, repository: zypp (download.opensuse.org-oss_2) ]

Try installing with:
    sudo zypper install krita

rokejulianlockhart@localhost:~> krita
If 'krita' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf krita


@rokejulianlockhart use the full path…

cnf cnf
Program 'cnf' is present in package 'scout-command-not-found', which is installed on your system.

Absolute path to 'cnf' is '/usr/bin/cnf'. Please check your $PATH variable to see whether it contains the mentioned path.

zypper se --provides --match-exact /usr/bin/cnf

S | Name                    | Summary                               | Type
i | scout-command-not-found | Command Not Found extension for shell | package

zypper se --provides --match-exact /usr/bin/krita

S | Name  | Summary                      | Type
  | krita | Digital Painting Application | package
1 Like

To answer your question - because your expectation is incorrect. And to explain what is incorrect, you need to describe what you expect. Not just dump some command lines without a single word of explanation.

The linked Stack Overflow question was the context provided. I did not expect to need to duplicate the content of the question asked there into this post, if that is what you refer to.

Thanks. Any reason why it doesn’t search $PATH by default?

@rokejulianlockhart it’s inspecting the package not the system, since your looking in most cases for something that is not installed.

1 Like

The $PATH environment variable is used by the shell (and maybe by other software that think it is useful to hop on the same feature) to search for the file of an executable that is only specified by it’s name (and not qualified by any path) on the place where a command is expected.

I do not see a connection with your zypper command that should tell you which package (installed or not) contains a file (maybe an executable when installed, but that only by incident) specified by it’s name.

@hcvv, I mentioned the env var indeed because I believed that the aforestated command different package managers’ counterparts (such as dnf provides) were solely able to provide whether an executable binary in $PATH is provided by a package, and which.

Obviously, I was incorrect, and pleasantly so – being able to use the flag for any file is certainly superior.

You cannot search for any file in a package that is not installed because metadata does not contain full full file list.

1 Like

Thanks. Do you know whether that capability has been requested previously? If not, no worries; I’ll do so myself.