bash-completion completion functions not loaded when using guix home

  • Done
  • quality assurance status badge
Details
3 participants
  • Andrew Tropin
  • Maze
  • wolf
Owner
unassigned
Submitted by
Maze
Severity
normal
M
(address . bug-guix@gnu.org)
20220831073502.ru6dye2wbgc6vrbu@ubik.pkbd.org
I don't install bash-completion into my system profile and I use only
guix home to install user packages. I typically don't guix install any
packages.

While I do include the bash-completion package in my home configuration
file, the completion bash functions do not get loaded as needed, the
resulting user experience is as if bash-completion wasn't installed,
although .bashrc is edited in the typical way to load the main file
bash_completion. But, the shell code in bash_completion cannot find and
load the individual files containing the completion functions for
individual commands.

The reason is that I don't have a ~/.guix-profile folder, my current
user profile is linked in ~/.guix-home/profile. The relevant path (in
my case) is not included in the search path for completion bash functions.

In guix this completion functions search path is defined by the patch found at
gnu/packages/patches/bash-completion-directories.patch, where you can
see the path to the guix home user profile is missing.

The patch below is a patch to the patch file I mention above from the
guix dource tree. It just adds 2 folders to the search path.

I verified that it works for me.

---
bash-completion: fix loading of completion functions with guix home

* gnu/packages/patches/bash-completion-directories.patch: modified
---
gnu/packages/patches/bash-completion-directories.patch | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Toggle diff (26 lines)
diff --git a/gnu/packages/patches/bash-completion-directories.patch b/gnu/packages/patches/bash-completion-directories.patch
index 021e34653b..3c6b3082ea 100644
--- a/gnu/packages/patches/bash-completion-directories.patch
+++ b/gnu/packages/patches/bash-completion-directories.patch
@@ -10,7 +10,7 @@ This is what this patch does.
--- a/bash_completion
+++ b/bash_completion
-@@ -2016,7 +2016,13 @@ complete -F _minimal ''
+@@ -2016,7 +2016,15 @@ complete -F _minimal ''
__load_completion()
{
@@ -19,6 +19,8 @@ This is what this patch does.
+ ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions
+ "$HOME/.guix-profile/share/bash-completion/completions/$base"
+ "$HOME/.guix-profile/etc/bash_completion.d/$base"
++ "$HOME/.guix-home/profile/share/bash-completion/completions/$base"
++ "$HOME/.guix-home/profile/etc/bash_completion.d/$base"
+ "/run/current-system/profile/share/bash-completion/completions/$base"
+ "/run/current-system/profile/etc/bash_completion.d/$base" )
+

base-commit: 47c11772dfe840a536ed7ec438fe832878f51054
--
2.36.1
A
A
Andrew Tropin wrote on 31 Aug 2022 13:55
87wnaok4ol.fsf@trop.in
On 2022-08-31 15:35, maze@pkbd.org wrote:

Toggle quote (25 lines)
> I don't install bash-completion into my system profile and I use only
> guix home to install user packages. I typically don't guix install any
> packages.
>
> While I do include the bash-completion package in my home configuration
> file, the completion bash functions do not get loaded as needed, the
> resulting user experience is as if bash-completion wasn't installed,
> although .bashrc is edited in the typical way to load the main file
> bash_completion. But, the shell code in bash_completion cannot find and
> load the individual files containing the completion functions for
> individual commands.
>
> The reason is that I don't have a ~/.guix-profile folder, my current
> user profile is linked in ~/.guix-home/profile. The relevant path (in
> my case) is not included in the search path for completion bash functions.
>
> In guix this completion functions search path is defined by the patch found at
> gnu/packages/patches/bash-completion-directories.patch, where you can
> see the path to the guix home user profile is missing.
>
> The patch below is a patch to the patch file I mention above from the
> guix dource tree. It just adds 2 folders to the search path.
>
> I verified that it works for me.

Hi Maze!

That's right, the similiar fix is already applied on core-updates branch
675c5c9bbd28e5e666903aa81efaec25b1573811, unfortunately bash-completion
package update affects a lot of packages that's why it's not on master
branch yet. Thank you for the patch, anyway!

For now, while 1.4 is not released yet, as a temporary fix I can suggest
to install the package providing bash-completion to ~/.guix-profile or
system profile. There are other workarounds, but this one seems to be
the easiest.

Toggle quote (26 lines)
>
> ---
> bash-completion: fix loading of completion functions with guix home
>
> * gnu/packages/patches/bash-completion-directories.patch: modified
> ---
> gnu/packages/patches/bash-completion-directories.patch | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/patches/bash-completion-directories.patch b/gnu/packages/patches/bash-completion-directories.patch
> index 021e34653b..3c6b3082ea 100644
> --- a/gnu/packages/patches/bash-completion-directories.patch
> +++ b/gnu/packages/patches/bash-completion-directories.patch
> @@ -10,7 +10,7 @@ This is what this patch does.
>
> --- a/bash_completion
> +++ b/bash_completion
> -@@ -2016,7 +2016,13 @@ complete -F _minimal ''
> +@@ -2016,7 +2016,15 @@ complete -F _minimal ''
>
> __load_completion()
> {
> @@ -19,6 +19,8 @@ This is what this patch does.
> + ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions
> + "$HOME/.guix-profile/share/bash-completion/completions/$base"

It seems $base not needed anymore, it's a rudiment from an old version
of the patch. I'll remove it.

Toggle quote (10 lines)
> + "$HOME/.guix-profile/etc/bash_completion.d/$base"
> ++ "$HOME/.guix-home/profile/share/bash-completion/completions/$base"
> ++ "$HOME/.guix-home/profile/etc/bash_completion.d/$base"
> + "/run/current-system/profile/share/bash-completion/completions/$base"
> + "/run/current-system/profile/etc/bash_completion.d/$base" )
> +
>
> base-commit: 47c11772dfe840a536ed7ec438fe832878f51054


--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmMPTEoACgkQIgjSCVjB
3rBNqQ//c3g0a0B4/IH8fNideDyAbiFA2OciLUOjPU1ipMRzrRQKRidO7TixBAnz
8ayrFhsbQ8dnYlcoXo2R1Uj5ACT9VF7xqKMw98JwOmfQnm0t9eME/fOVyvS+2ujx
oLtngqoJs/jp7EdyfHJI0Kk9GrepoFFY5rFuZ5LWSar7mvWopqZzRsNQF18Ryw3R
csQN4YeWc/qUXVau+ZGtJj26Rr9NcblAqSU/rLydugMyiV81WEXS5wO03fjmYpZC
XiESa1wOEmqil9Sdjzwdn5VcgKL4Otfo8cF/uLN/ROUtrTWigiaFdhN9aQv7dudO
2WUgPBquXNO/k08BH35a3GJudryZdni8dSFH1SnNjsTLbYW7QYH8yiikiumpS8K0
YVvw5zjmpWd1Z8b5t+Hd7/xGw011msX4P6cHSoClvDEYZ+BC5/Ocdtrm7BooSlXP
ObX4FX2PGazIh1096XiY/JdV4mqK6uVg9Ls2LWmN7ysl+dJv466wqFcHIgQ3GWIa
tdnhPac9Bv2tkH7Px5ySPrEZNAIO1YP70ABXx2kNAcgjXXyRBJIqFke3l1cDO3yQ
8rJ6mCS3KVe/2DRqQCcSmu7WfdyNnQbxOnvjgDPnO+Gs+hD44O48xE08odHGT8R9
tTgo4vKAv08jv4nML7Am3YG9qdRedOGY5yERPn/XWQR/FUTpl/g=
=eE/9
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 31 Aug 2022 13:58
Already fixed on core-updates
(address . control@debbugs.gnu.org)
87tu5sk4kg.fsf@trop.in
close 57498
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmMPTN8ACgkQIgjSCVjB
3rDvxw/6AmwjKVR7HZXu9BXsHtjVa/ar5CUGb8fkcW3OUd7IM35EXlfkdgZOt2LG
N2Mu1sk5lDx+WfLnNE5QrfnrWXuSOTwxMCFmrKNUmPg9JGxkj0R7lCvhgym9AwOy
vqoDTjwy9sjbYIlZMdLXPHYnPUXjr9D5HXpIhcGz3r+2Jj+RMNzR3uLurQipFbmr
V4+RNoD+fPGEN5s9yThoe3iuVGMx7tGMdf8tRbpeqR1q/85Uo5ZQGUHEMbBIp6Nq
RBfnqRLU+dUQ/03+7PeBuKPTb2ZuIC58U1Z1ln5WUMQ2RPxrGmvzXrRQqtYjZf7l
dJfdfKaTB2dr7Sl/iz0rhPHpnfbPXJehPr9YE5szwSCFb77PaOjiovK9v2QIXbpI
y9m7BaCbNn/9FDei5aCMNGsk77/J8znQPWxIQcjBhof83AhNpp+BfACGmZPe+SCD
yo31+8jug/T0zT5kTpEzLgp61nsJIuCvn07rGBDKrZUikwKBrPLTkE7UDEZMiB7V
e+CFrfFubAznaSvsezp8A0u5T3X6xNf1ooYfN1MgRae3IeURL1yWMmwl98msHp7Z
U/bNIqnOgkmn4fnxW5IbElP4/6zwj2prT4gsX6JAcUcbCNoLBbQh9hKXErFVeUAo
EpVSb80ClTDRK+vp3qA/sYvISadCjEImOp8/ZMrlfymzoRXLSmg=
=fc3M
-----END PGP SIGNATURE-----

M
Re: bug#57498: bash-completion completion functions not loaded when using guix home
(name . Andrew Tropin)(address . andrew@trop.in)
20220831122122.wsyvyxm56tdt7zkm@ubik.pkbd.org
Thanks for the information and right, it is easy to workaround once
figured out. Next time I find a little thing of this sort I'll be sure to
check on the core-updates branch.

On Wednesday 31 August 2022 at 02:55:54PM, Andrew Tropin has written:
Toggle quote (84 lines)
> On 2022-08-31 15:35, maze@pkbd.org wrote:
>
> > I don't install bash-completion into my system profile and I use only
> > guix home to install user packages. I typically don't guix install any
> > packages.
> >
> > While I do include the bash-completion package in my home configuration
> > file, the completion bash functions do not get loaded as needed, the
> > resulting user experience is as if bash-completion wasn't installed,
> > although .bashrc is edited in the typical way to load the main file
> > bash_completion. But, the shell code in bash_completion cannot find and
> > load the individual files containing the completion functions for
> > individual commands.
> >
> > The reason is that I don't have a ~/.guix-profile folder, my current
> > user profile is linked in ~/.guix-home/profile. The relevant path (in
> > my case) is not included in the search path for completion bash functions.
> >
> > In guix this completion functions search path is defined by the patch found at
> > gnu/packages/patches/bash-completion-directories.patch, where you can
> > see the path to the guix home user profile is missing.
> >
> > The patch below is a patch to the patch file I mention above from the
> > guix dource tree. It just adds 2 folders to the search path.
> >
> > I verified that it works for me.
>
> Hi Maze!
>
> That's right, the similiar fix is already applied on core-updates branch
> 675c5c9bbd28e5e666903aa81efaec25b1573811, unfortunately bash-completion
> package update affects a lot of packages that's why it's not on master
> branch yet. Thank you for the patch, anyway!
>
> For now, while 1.4 is not released yet, as a temporary fix I can suggest
> to install the package providing bash-completion to ~/.guix-profile or
> system profile. There are other workarounds, but this one seems to be
> the easiest.
>
> >
> > ---
> > bash-completion: fix loading of completion functions with guix home
> >
> > * gnu/packages/patches/bash-completion-directories.patch: modified
> > ---
> > gnu/packages/patches/bash-completion-directories.patch | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/gnu/packages/patches/bash-completion-directories.patch b/gnu/packages/patches/bash-completion-directories.patch
> > index 021e34653b..3c6b3082ea 100644
> > --- a/gnu/packages/patches/bash-completion-directories.patch
> > +++ b/gnu/packages/patches/bash-completion-directories.patch
> > @@ -10,7 +10,7 @@ This is what this patch does.
> >
> > --- a/bash_completion
> > +++ b/bash_completion
> > -@@ -2016,7 +2016,13 @@ complete -F _minimal ''
> > +@@ -2016,7 +2016,15 @@ complete -F _minimal ''
> >
> > __load_completion()
> > {
> > @@ -19,6 +19,8 @@ This is what this patch does.
> > + ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions
> > + "$HOME/.guix-profile/share/bash-completion/completions/$base"
>
> It seems $base not needed anymore, it's a rudiment from an old version
> of the patch. I'll remove it.
>
> > + "$HOME/.guix-profile/etc/bash_completion.d/$base"
> > ++ "$HOME/.guix-home/profile/share/bash-completion/completions/$base"
> > ++ "$HOME/.guix-home/profile/etc/bash_completion.d/$base"
> > + "/run/current-system/profile/share/bash-completion/completions/$base"
> > + "/run/current-system/profile/etc/bash_completion.d/$base" )
> > +
> >
> > base-commit: 47c11772dfe840a536ed7ec438fe832878f51054
>
>
> --
> Best regards,
> Andrew Tropin



--
Maze
W
unarchive 57498
(address . control@debbugs.gnu.org)
ZBWhoq5MdUKNvMsP@ws
unarchive 57498
W
Re: bug#57498: bash-completion completion functions not loaded when using guix home
(address . 57498@debbugs.gnu.org)
ZBWeNy7yD5N+/m/F@ws
Hi,

if anyone else runs into this before the core-updates merge happens, reasonably
simple solution without installing packages into other profiles (or system-wide)
seems to be to add following into services in home definition:

;; TODO: https://issues.guix.gnu.org/57498,should not be necessary after
;; core-updates merge
(simple-service 'guix-home-bash-completion home-bash-service-type
(home-bash-extension
(bashrc (list (plain-file "load-guix-home-bash-completion" "
for f in ~/.guix-home/profile/etc/bash_completion.d/* ~/.guix-home/profile/share/bash-completion/completions/*; do
[ -r \"$f\" ] && . \"$f\"
done")))))

Leaving it here since it might be useful to someone.

W.

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmQVnjcACgkQL7/ufbZ/
wanHrA//UoDE/wQLc/TUeCLsBvH06YnAoItR62HMR/gS2jxUh1BR9U2bsxCMv9v0
QIFS83bbn0ZlKjgGAVw5ero1jh8vlASfc9DxHjrLhhYJBvmXj99Q85t6R4ysBdjy
YDqAMyoseI/D0+6Slg/SmZQTUFW2iqTU92dOvRqd9qVZy+9hz0bObm8bULIj9pKT
MwaystraU7xac7crAdDraCxG3ZaSBzPL/8iEbiYZ+k+EqYtYhSFJLyEDX6c2Tem/
XHXImNnp+YfzZWJvt2+ps+7RM4CoU+BRRNxtOSrCykcyV17s3wDoMvEd69ONSm1q
m/oqu6fszwBj9JR5wEUW4oTL9EIi6S3fdSFEu8Aw1W1HtAtLi4CWSlOl5aVnVqRb
i/pH73LJ2/XkddXLK2WP2uOhuLzXv/2B4rbdR2i/3QlRQk29ZbfYVET1y/FLRIIC
2e9SOt0LWisIa62d61KrAzeBCethZvjnpm7/j7++txXoAvwrpyQY7j2GstVy8UTb
1DPJloA07yaonfIC2s5lc1bLQCR60377Nei1MGsmpOTImdLl0w5KocA3USqNzSty
ClUd7s4gM8SYUSJJhOESuHcuPFwS12/WNzhewJNIT6oJGfFaJ/epq1doLmJVcpq1
r5xFJ9gJ/37wgYrDYjZ+v8ap4/g+w+b2yY+wywA72xFGxYJfSYY=
=MgzC
-----END PGP SIGNATURE-----


?