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

"compgen: command not found" while typing #399

Open
matthiasbeyer opened this issue Feb 2, 2024 · 16 comments
Open

"compgen: command not found" while typing #399

matthiasbeyer opened this issue Feb 2, 2024 · 16 comments

Comments

@matthiasbeyer
Copy link

ble version: 0.4.0-devel3+1a5c451c
Bash version: 5.2.15(1)-release (x86_64-pc-linux-gnu)

I am not 100% positive that this is actually an issue with blesh, but it never happened before I installed blesh, so this is where I think posting this issue is the best way to start:

image

The error you see happened while typing, no TAB was hit or something like that, just simple typing.
I am not sure what to do to debug this, though.

@akinomyoga
Copy link
Owner

I'm not sure what is happening there either. At least, I've never hit this behavior in my environment.

I think this is related to completions because compgen is a Bash builtin command that is used for programmable completions. So the first thing to check is whether it is caused inside auto-complete (i.e., the autosuggestion feature of ble.sh).

  • Q1: Does the behavior persist after disabling auto-complete by the following command?
$ bleopt complete_auto_complete=
  • Q2: Also, could you provide the results of the following command?
$ ble/widget/display-shell-version

I have also other questions, but I'll ask them after checking an answer to Q1.

@akinomyoga
Copy link
Owner

I've found something similar at NixOS/nixpkgs#157882, though it seems to be reported against Zsh.

@akinomyoga
Copy link
Owner

  • Q3: What are the results of the following commands?
$ complete -p git
$ type compgen
  • Q4: Could you run the following command, reproduce the error messages, and see if a file ~/debug.txt is created? If it is created, could you provide its content? After the test, you can delete the file ~/debug.txt.
$ ble/function#advice before git 'echo "${ADVICE_WORDS[@]}" >> ~/debug.txt'
$ git annex .... # <-- here, please input something and try to reproduce the error messages
  • Q5: What is the value of SHELL?
$ echo "$SHELL"
  • Q5a: If the value of SHELL is not Bash, when SHELL is set to a path to Bash, does the issue reproduce?
$ export SHELL=$BASH
$ git annex .l.. # <-- see if the error messages appear
  • Q6: What is your login shell? [ Note: I'm not asking about the shell that you are currently running or the value of SHELL. I'm asking for the login shell associated with your user account in the system. ]
$ getent passwd | awk -F : -v UID="$UID" '$3==UID {print $7}'
  • Q6a: If your login shell is not Bash, could you temporarily change the login shell to Bash to see if the problem still reproduces? After checking, you can revert the login shell.

@akinomyoga
Copy link
Owner

akinomyoga commented Feb 2, 2024

  • Q1a: If the answer to Q1 is that the problem stops by disabling auto-complete, with that setting, does the TAB completion produce a similar error message?
$ bleopt complete_auto_complete=
$ git annex ... [press TAB here]
  • Q7: Does the problem persist after running the following command?
$ ble/function#push enable true
$ git annex ... # <-- see if the error messages reproduce

@akinomyoga
Copy link
Owner

This seems to be related: dhall-lang/dhall-haskell#2362

Hmm, the discussion there reminds me of another discussion started at #169 (comment).

  • Q8: What are the results of the following commands?
$ echo "$BASH"
$ readlink /proc/$$/exe
  • Q8a: If the results of the two commands in Q8 are different, does the problem reproduce after rewriting BASH in this way?
$ BASH=$(readlink /proc/$$/exe)
$ git annex ... # <-- does the problem reproduce here?
  • Q9: What is the result of the following command?
$ type -a bash

@matthiasbeyer
Copy link
Author

Fun thing is: I cannot reproduce the issue right now, so I cannot answer all your questions right now... I'll answer everything else as good as I can:


Q1: Does the behavior persist after disabling auto-complete by the following command?

bleopt complete_auto_complete=

Cannot answer right now, because I cannot reproduce.

Q2: Also, could you provide the results of the following command?

GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu) [NixOS 23.11 (Tapir)]
ble.sh, version 0.4.0-devel3+1a5c451c (noarch) [git 2.39.0, GNU Make 4.3, GNU Awk 5.1.1, API: 3.1 (GNU MPFR 4.1.0-p13, GNU MP 6.2.1)]
bash-completion, version 2.11 (hash:19e2694965e22296373454c974d11a309db1e89c, 76396 bytes) (noarch)
fzf key-bindings, (hash:66601b132b32248c0b47926f99fd02832ba06892, 5577 bytes) (noarch)
WARNING: fzf integration "integration/fzf-key-bindings" is not activated.
fzf completion, (hash:db84e06a1ee5fb43bc6ad1aaeec6657cad79c917, 14523 bytes) (noarch)
WARNING: fzf integration "integration/fzf-completion" is not activated.
starship, version 1.17.1 (rustc 1.73.0 (cc66ad468 2023-10-03) (built from a source tarball), 1980-01-01 00:00:00 +00:00)
locale: LANG=de_DE.UTF-8
terminal: TERM=xterm-256color wcwidth=15.0-west/15.0-2+ri, konsole:220380 (1;115;0)

Q3: What are the results of the following commands?

$ complete -p git
complete -o bashdefault -o default -o nospace -F __git_wrap__git_main git
$ type compgen
compgen is a shell builtin

Q4: Could you run the following command, reproduce the error messages, and see if a file ~/debug.txt is created? If it is created, could you provide its content? After the test, you can delete the file ~/debug.txt.

$ ble/function#advice before git 'echo "${ADVICE_WORDS[@]}" >> ~/debug.txt'
$ git annex .... # <-- here, please input something and try to reproduce the error messages

Cannot answer right now, because I cannot reproduce.

Q5: What is the value of SHELL?

/var/run/current-system/sw/bin/bash

Q5a: If the value of SHELL is not Bash, when SHELL is set to a path to Bash, does the issue reproduce?

Not applicable, $SHELL == $BASH

Q6: What is your login shell?

$ getent passwd | awk -F : -v UID="$UID" '$3==UID {print $7}'
/var/run/current-system/sw/bin/bash

Q6a: If your login shell is not Bash, could you temporarily change the login shell to Bash to see if the problem still reproduces? After checking, you can revert the login shell.

Not applicable, login shell is bash.

@akinomyoga
Copy link
Owner

Fun thing is: I cannot reproduce the issue right now, so I cannot answer all your questions right now... I'll answer everything else as good as I can:

I see. Thank you for all your answers. If this issue is related to dhall-lang/dhall-haskell#2362 or #169 (comment) mentioned above, maybe the problem only arises in nix-shell, nix shell, or nix develop.

@akinomyoga
Copy link
Owner

akinomyoga commented Feb 9, 2024

@matthiasbeyer Have you faced the same problem after that?

@matthiasbeyer
Copy link
Author

Yes, and it seems to be a nix shell issue indeed.

@akinomyoga
Copy link
Owner

Thank you for the information. I'm wondering what would be the solution for this issue.

I here assume that the root cause is the same as the problem mentioned in #169 (comment). If that is the case, as I mentioned there, I'd like to request nix shell to stop overwriting the shell variable BASH with something like a dumb version of Bash if possible. What do you think?

If there is a strong reason that the current behavior of nix shell cannot be changed, I might need to think about a workaround. In that case, could you check the results of Q8, Q8a, and Q9 inside nix shell environment (where the problem reproduces)?

@matthiasbeyer
Copy link
Author

I finally came around to answer the questions you mentioned:

Q8:

$ echo "$BASH"                                                                                                                                                                                                                                                                                     
/nix/store/x88ivkf7rmrhd5x3cvyv5vh3zqqdnhsk-bash-interactive-5.2-p15/bin/bash                                                                                                                                                                                                                                                  
$ readlink /proc/$$/exe                                                                                                                                                                                                                                                                             
/nix/store/x88ivkf7rmrhd5x3cvyv5vh3zqqdnhsk-bash-interactive-5.2-p15/bin/bash

Q8a: not applicable

Q9:

$ type -a bash
bash ist /nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin/bash                                                                                                                                                                                                                                                     
bash ist /run/current-system/sw/bin/bash

@akinomyoga
Copy link
Owner

Thanks!

  • Q10: Could you also try the following commands inside nix shell?
$ type compgen
$ "$BASH" -c 'type compgen'
$ "$BASH" -c 'comgpen -W "test{1..3}"'
$ bash -c 'type compgen'
$ bash -c 'compgen -W "test{1..3}"'
$ /run/current-system/sw/bin/bash -c 'type compgen'
$ /run/current-system/sw/bin/bash -c 'compgen -W "test{1..3}"'

@matthiasbeyer
Copy link
Author

Here we go (sorry for the german locale 😆 ):

$ type compgen                                                                                                                                                                                                                                                                                         
compgen ist eine von der Shell mitgelieferte Funktion.                                                                                                                                                                                                                                                                         

$ "$BASH" -c 'type compgen'                                                                                                                                                                                                                                                                            
compgen ist eine von der Shell mitgelieferte Funktion.                                                                                                                                                                                                                                                                         

$ "$BASH" -c 'comgpen -W "test{1..3}"'                                                                                                                                                                                                                                                                 
/nix/store/x88ivkf7rmrhd5x3cvyv5vh3zqqdnhsk-bash-interactive-5.2-p15/bin/bash: Zeile 1: comgpen: Kommando nicht gefunden.                                                                                                                                                                                                      
[ble: exit 127]                                                                                                                                                                                                                                                                                                                

$ bash -c 'type compgen'                                                                                                                                                                                                                                                                               
bash: line 1: type: compgen: not found                                                                                                                                                                                                                                                                                         
[ble: exit 1]                                                                                                                                                                                                                                                                                                                  

$ bash -c 'compgen -W "test{1..3}"'                                                                                                                                                                                                                                                                    
bash: line 1: compgen: command not found                                                                                                                                                                                                                                                                                       
[ble: exit 127]                                                                                                                                                                                                                                                                                                                

$ /run/current-system/sw/bin/bash -c 'type compgen'                                                                                                                                                                                                                                                    
compgen ist eine von der Shell mitgelieferte Funktion.                                                                                                                                                                                                                                                                         

$ /run/current-system/sw/bin/bash -c 'compgen -W "test{1..3}"'                                                                                                                                                                                                                                         
test1                                                                                                                                                                                                                                                                                                                          
test2                                                                                                                                                                                                                                                                                                                          
test3 

@akinomyoga
Copy link
Owner

akinomyoga commented Mar 12, 2024

Thanks. Hmm, it seems the error message is produced by another process called as bash (which points to /nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin/bash). Since ble.sh doesn't call the command bash, the error message might be produced in a third-party setting for some completion settings.

  • Q11: Is the error message reproducible in the detached state of ble.sh?
$ ble-detach
$  stty sane;
$ git annex copy [TAB]

Could you press TAB in the above position marked as [TAB]? ([TAB] is not the string to input) Here, git annex copy would be a string that causes the error message of "compgen not found" in ble.sh's session.

@matthiasbeyer
Copy link
Author

image

yes, it is indeed reproducible... 🤔 👀

@akinomyoga
Copy link
Owner

Thanks! Then, I guess it's unrelated to ble.sh.

  • Q12: To confirm, could you disable ble.sh in ~/.bashrc and see if the problem reproduces with git annex copy [TAB]?
  • Q13: I think it should be useful to check Bash's debug trace. Could you try the following in nix shell without ble.sh?
$ exec {BASH_XTRACEFD}> debug.txt
$ set -x
$ git annex copy bash [TAB]
$ set +x

Then, could you share the content of debug.txt? You can attach a text file by dropping the file in GitHub's textbox.

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