* Re: [EXTERNAL] Re: Unexpected installation of SQLite during "sudo dnf autoremove" command
2023-07-11 8:12 ` Mirko Matošin
@ 2023-07-11 8:46 ` Roman Perepelitsa
2023-07-11 10:17 ` Jun T
2023-07-11 16:25 ` Bart Schaefer
2 siblings, 0 replies; 9+ messages in thread
From: Roman Perepelitsa @ 2023-07-11 8:46 UTC (permalink / raw)
To: Mirko Matošin; +Cc: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 1026 bytes --]
On Tue, Jul 11, 2023 at 10:12 AM Mirko Matošin
<mirko.matosin@zimmer-group.com> wrote:
>
> As soon as i hit tab after autoremove it wants to install sqlite
>
> mirko@fedora ~$ sudo dnf autoremove zsh: sqlite3: Befehl nicht gefunden...
> Soll das Paket »sqlite« installiert werden, welches den Befehl »sqlite3« bereitstellt? [N/y]
> ```
It works fine for me in docker:
% docker run -e LC_ALL=C.UTF-8 -e TERM -it --rm fedora bash -uexc '
yum update -y
yum install -y zsh
exec zsh'
[root@8846ed956e61]~# autoload -Uz compinit
[root@8846ed956e61]~# compinit
[root@8846ed956e61]~# dnf autoremove [TAB]
zsh: do you wish to see all 149 possibilities (149 lines)?
I see that Completion/Redhat/Command/_dnf invokes sqlite3
conditionally if /var/cache/dnf/packages.db exists. On my system
neither this file nor sqlite3 exist but on yours the file must exist
but not sqlite3, hence the error. Perhaps _dnf should have another
condition in there?
Roman.
[-- Attachment #2: dnf-sqlite3.patch.txt --]
[-- Type: text/plain, Size: 567 bytes --]
diff --git a/Completion/Redhat/Command/_dnf b/Completion/Redhat/Command/_dnf
index ce111f38f..0f2e42a81 100644
--- a/Completion/Redhat/Command/_dnf
+++ b/Completion/Redhat/Command/_dnf
@@ -40,7 +40,7 @@ _dnf_packages() {
selected=$selected[2]
if [[ $selected = upgradable ]]; then
pkgs=( $(_dnf_helper upgrade) )
- elif [[ -r $cache_file ]]; then
+ elif [[ -v commands[sqlite3] && -r $cache_file ]]; then
local table=$selected
# 'available' table contains both 'available' and 'installed' packages
[[ $selected = all ]] && table=available
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [EXTERNAL] Re: Unexpected installation of SQLite during "sudo dnf autoremove" command
2023-07-11 8:12 ` Mirko Matošin
2023-07-11 8:46 ` Roman Perepelitsa
@ 2023-07-11 10:17 ` Jun T
2023-07-11 10:23 ` Jun T
2023-07-11 16:25 ` Bart Schaefer
2 siblings, 1 reply; 9+ messages in thread
From: Jun T @ 2023-07-11 10:17 UTC (permalink / raw)
To: zsh-workers
> 2023/07/11 17:12、Mirko Matošin <mirko.matosin@zimmer-group.com>のメール:
>
> As soon as i hit tab after autoremove it wants to install sqlite
In my case I get:
Install package 'sqlite' to provide command 'sqlite3'? [N/y]
and just hitting RETURN does not install sqlite
(although the screen is rather cluttered).
> 2023/07/11 17:46、Roman Perepelitsa <roman.perepelitsa@gmail.com>のメール:
>
> I see that Completion/Redhat/Command/_dnf invokes sqlite3
> conditionally if /var/cache/dnf/packages.db exists.
So we can avoid calling sqlite3 if the command is not available,
as in the patch below.
But the completion is somewhat faster if you have sqlite3 command
(one or two seconds vs. almost instant?).
What is the best way to inform users that installing sqlite package
will make the completion (somewhat) faster?
Or is the completion reasonably fast even without sqlite3?
# If I remember correctly, a few or several years ago, completing
# package names without sqlite3 was much slower (this may be just my
# wrong memory). But anyway it is still slower
diff --git a/Completion/Redhat/Command/_dnf b/Completion/Redhat/Command/_dnf
index ce111f38f..3fbd73352 100644
--- a/Completion/Redhat/Command/_dnf
+++ b/Completion/Redhat/Command/_dnf
@@ -40,7 +40,7 @@ _dnf_packages() {
selected=$selected[2]
if [[ $selected = upgradable ]]; then
pkgs=( $(_dnf_helper upgrade) )
- elif [[ -r $cache_file ]]; then
+ elif [[ -r $cache_file && -n $commands[sqlite3] ]]; then
local table=$selected
# 'available' table contains both 'available' and 'installed' packages
[[ $selected = all ]] && table=available
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [EXTERNAL] Re: Unexpected installation of SQLite during "sudo dnf autoremove" command
2023-07-11 10:17 ` Jun T
@ 2023-07-11 10:23 ` Jun T
0 siblings, 0 replies; 9+ messages in thread
From: Jun T @ 2023-07-11 10:23 UTC (permalink / raw)
To: zsh-workers
> 2023/07/11 19:17、Jun T <takimoto-j@kba.biglobe.ne.jp>のメール:
>
> So we can avoid calling sqlite3 if the command is not available,
> as in the patch below.
Sorry, I didn't noticed the attachment file in Roman's post.
The patch is the same as his attachment.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [EXTERNAL] Re: Unexpected installation of SQLite during "sudo dnf autoremove" command
2023-07-11 8:12 ` Mirko Matošin
2023-07-11 8:46 ` Roman Perepelitsa
2023-07-11 10:17 ` Jun T
@ 2023-07-11 16:25 ` Bart Schaefer
2023-07-11 20:53 ` Roman Perepelitsa
2 siblings, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2023-07-11 16:25 UTC (permalink / raw)
To: Mirko Matošin; +Cc: zsh-workers
On Tue, Jul 11, 2023 at 1:12 AM Mirko Matošin
<mirko.matosin@zimmer-group.com> wrote:
>
> As soon as i hit tab after autoremove it wants to install sqlite
I'm reasonably sure this is not a problem with zsh or completion per
se, but rather that the packaged OS vendor installation includes a
command-not-found handler that invokes the package manager.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [EXTERNAL] Re: Unexpected installation of SQLite during "sudo dnf autoremove" command
2023-07-11 16:25 ` Bart Schaefer
@ 2023-07-11 20:53 ` Roman Perepelitsa
0 siblings, 0 replies; 9+ messages in thread
From: Roman Perepelitsa @ 2023-07-11 20:53 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Mirko Matošin, zsh-workers
On Tue, Jul 11, 2023 at 6:26 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Tue, Jul 11, 2023 at 1:12 AM Mirko Matošin
> <mirko.matosin@zimmer-group.com> wrote:
> >
> > As soon as i hit tab after autoremove it wants to install sqlite
>
> I'm reasonably sure this is not a problem with zsh or completion per
> se, but rather that the packaged OS vendor installation includes a
> command-not-found handler that invokes the package manager.
_dnf invokes sqlite3 as an optimization. There is a fallback branch
that does not require this command. However, the optimization branch
may be taken even when sqlite3 is missing. This is a bug in _dnf.
Either of the two patches posted here will fix it.
Roman.
^ permalink raw reply [flat|nested] 9+ messages in thread