Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash-completions-getter.sh: line 178: _completion_loader: command not found #5

Open
wentasah opened this issue Oct 23, 2020 · 2 comments

Comments

@wentasah
Copy link

I'm trying to make this work on NixOS and I'm getting the following error:

/nix/store/0ibqj2ysg8602by5azn2rgm64w6gmsnd-source/bash-completions-getter.sh: line 178: _completion_loader: command not found

It seems that when bash is run in non-interactive mode, this function is not defined on NixOS. I can resolve the issue with the following change, but I'm not sure how generic it is and whether it would work on other distributions.

diff --git a/zsh-bash-completions-fallback.plugin.zsh b/zsh-bash-completions-fallback.plugin.zsh
index 61402cb..4609ff9 100644
--- a/zsh-bash-completions-fallback.plugin.zsh
+++ b/zsh-bash-completions-fallback.plugin.zsh
@@ -12,7 +12,7 @@ function _bash_completions_fallback_completer {
         ZSH_WORDBREAKS="$WORDCHARS" \
         ZSH_WORDS="${words[@]}" \
         ZSH_CURRENT=$((CURRENT-1)) \
-        bash -c \
+        bash -i -c \
         "source ${_bash_completions_getter_path}; get_completions")}");
 
     local -a -U bopts=("${(ps: :)${(@f)out:0:1}}");
@@ -83,7 +83,7 @@ function _bash_completions_fetch_supported_commands {
 
     if [ -n "${ZSH_BASH_COMPLETIONS_FALLBACK_LOAD_NATIVE_COMPLETIONS-:true}" ]; then
         local out=("${(u@f)$( \
-            bash -c \
+            bash -i -c \
             "source ${_bash_completions_getter_path}; get_defined_completions")}");
         _bash_completions_commands+=($out)
     fi
@3v1n0
Copy link
Owner

3v1n0 commented Nov 9, 2020

well, it would likely work in other platforms, but indeed will make things slower (depending on your default default .bashrc)

Maybe, can you try if instead you can just try to ensure that a function defined in /usr/share/bash-completion/bash_completion (or well yours) exists and in such case source it? Would be that enough?

Otherwise, something else we could probably do for everyone is something like this:

env HOME="/tmp/fooo" DEFAULT_HOME="$HOME" bash -i -c "export HOME=$DEFAULT_HOME; echo do stuff in $HOME"

So that we won't ever end up loading the user's .bashrc, but we still be using its HOME for other stuff.

@3v1n0
Copy link
Owner

3v1n0 commented Nov 9, 2020

Mh, loading the bash_completion is actually already happening, so what I assume is that we're picking the wrong location in your setup. Where is the bash_completion script?

I assume you've to fix source_bash_completion function in bash-completions-getter.sh instead, can you maybe do a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants