Description of problem: The page https://dnf.readthedocs.io/en/latest/api_queries.html describes now query() might be used. The first example shows: q = base.sack.query() i = q.installed() i = i.filter(name='pepper') packages = list(i) # i only gets evaluated here a = q.available() a = a.filter(name='pepper') for pkg in a: # a only gets evaluated here print(pkg.name) and the first part can be made working in standalone script as #!/usr/bin/python3 import dnf base = dnf.Base() base.fill_sack() q = base.sack.query() i = q.installed() for p in i: print(p, p.reponame) I myself would have preferred to have such a standalone example shown but the q.installed() part works well. However, the q.available() part does not work out of box -- running #!/usr/bin/python3 import dnf base = dnf.Base() base.fill_sack() q = base.sack.query() a = q.available() a = a.filter(name = "zsh") for p in a: print(p, p.reponame) does not print anything even if running dnf list zsh works fine. It'd be nice to have complete examples, not just snippets without context and without obvious way of making them working. Version-Release number of selected component (if applicable): dnf-4.0.9-2.fc29.noarch How reproducible: Deterministic. Steps to Reproduce: 1. Read https://dnf.readthedocs.io/en/latest/api_queries.html. 2. Be happy that there is available() which is documented to Return a new query limiting the original query to the not-installed packages, that is packages available from the repositories. 3. Based on the example snippet on that page, create and run script #!/usr/bin/python3 import dnf base = dnf.Base() base.fill_sack() q = base.sack.query() a = q.available() a = a.filter(name = "zsh") for p in a: print(p, p.reponame) Actual results: Nothing printed. Expected results: The zsh package information printed. Additional info: Of course, it's well possible that the example and my approach is correct and the bug is in the dnf code -- in that case the code should be fixed. ;-)
True, there is `base.read_all_repos()` line missing in the example just before base.fill_sack() line. Without this, dnf is working only with @System repo, so there are no "available" package. We will update the documentation.
Thanks. Confirming that adding base.read_all_repos() makes the code work: zsh-5.6.2-3.fc29.x86_64 updates zsh-5.6.2-1.fc29.x86_64 fedora
PR: https://github.com/rpm-software-management/dnf/pull/1421
FEDORA-2019-d4b6ede072 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-d4b6ede072
dnf-4.2.5-4.fc29, dnf-plugins-extras-4.0.4-2.fc29, libdnf-0.31.0-6.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-d4b6ede072
dnf-4.2.5-4.fc29, dnf-plugins-extras-4.0.4-2.fc29, libdnf-0.31.0-6.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.