unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57498: bash-completion completion functions not loaded when using guix home
@ 2022-08-31  7:35 Maze
  2022-08-31 11:55 ` Andrew Tropin
  2023-03-18 11:19 ` wolf
  0 siblings, 2 replies; 4+ messages in thread
From: Maze @ 2022-08-31  7:35 UTC (permalink / raw)
  To: 57498

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(-)

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





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#57498: bash-completion completion functions not loaded when using guix home
  2022-08-31  7:35 bug#57498: bash-completion completion functions not loaded when using guix home Maze
@ 2022-08-31 11:55 ` Andrew Tropin
  2022-08-31 12:21   ` Maze
  2023-03-18 11:19 ` wolf
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Tropin @ 2022-08-31 11:55 UTC (permalink / raw)
  To: Maze, 57498; +Cc: Ludovic Courtès, Tobias Geerinckx-Rice, Efraim Flashner

[-- Attachment #1: Type: text/plain, Size: 3448 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#57498: bash-completion completion functions not loaded when using guix home
  2022-08-31 11:55 ` Andrew Tropin
@ 2022-08-31 12:21   ` Maze
  0 siblings, 0 replies; 4+ messages in thread
From: Maze @ 2022-08-31 12:21 UTC (permalink / raw)
  To: Andrew Tropin
  Cc: 57498, Ludovic Courtès, Tobias Geerinckx-Rice,
	Efraim Flashner

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:
> 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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#57498: bash-completion completion functions not loaded when using guix home
  2022-08-31  7:35 bug#57498: bash-completion completion functions not loaded when using guix home Maze
  2022-08-31 11:55 ` Andrew Tropin
@ 2023-03-18 11:19 ` wolf
  1 sibling, 0 replies; 4+ messages in thread
From: wolf @ 2023-03-18 11:19 UTC (permalink / raw)
  To: 57498

[-- Attachment #1: Type: text/plain, Size: 831 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-18 11:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31  7:35 bug#57498: bash-completion completion functions not loaded when using guix home Maze
2022-08-31 11:55 ` Andrew Tropin
2022-08-31 12:21   ` Maze
2023-03-18 11:19 ` wolf

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).