5

I have created my own linux. Whenever I open up my bash and login into a sub-shell I get the following error

-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found

It is displayed several times. To debug it, I executed the following command:

bash --login -x

Output:

+ source /etc/locale.conf
++ LANG=en_US.UTF-8
+ for f in '/etc/bash_completion.d/*'
+ '[' -e /etc/bash_completion.d/grub ']'
+ source /etc/bash_completion.d/grub
+++ echo grub-set-default
+++ sed s,x,x,
++ __grub_set_default_program=grub-set-default
++ have grub-set-default
bash: have: command not found
++ unset __grub_set_default_program
+++ sed s,x,x,
+++ echo grub-reboot
++ __grub_reboot_program=grub-reboot
++ have grub-reboot
bash: have: command not found
++ unset __grub_reboot_program
+++ echo grub-editenv
+++ sed s,x,x,
++ __grub_editenv_program=grub-editenv
++ have grub-editenv
bash: have: command not found

The output is too long too be pasted here. But this snippet shows the error. The error is in the /etc/bash_completion.d/grub file. This file is calling have. Re-installing grub didn't fix the error. So, how do I solve this bug?

2

3 Answers 3

3

Seems like you are missing bash completion in your Linux.

See this post also 'have' keyword for bash completion

2

I got the problem after updating my debian server:

bigbear3001@server:/etc/openvpn$ sudo su -
-su: have: command not found
-su: have: command not found
...

I fixed it by commenting out the following lines in /usr/share/bash-completion/bash_completion at the end

unset -f have
unset have

Of course you can also fix all the scripts using have instead of _have

1
  • I have never had this issue before, but I have it now on Arch Linux with the completions of grub2:2.06.r456.g65bc45963-1. This helped me, but I am considering reporting it upstream. Mar 25, 2023 at 14:21
-1

I had the same issue after I'd installed git completion. The problem resolved by commenting these strings in .bashrc :

#Git completion script
#for file in /etc/bash_completion.d/* ; do 
#       source "$file"
#done

So, now it works clear:

user@linux~>

and no

 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
2
  • 1
    the issue is if you comment out that for statement, you won't get the benefit of the custom completion scripts in the /etc/bash_completion.d directory. I vote this response down. But I am having the same issue with the custom grub auto-completion found in /etc/bash_completion.d directory. so doing '. /etc/bash_completion' is not working as expected. Dec 11, 2017 at 18:37
  • @RaymondBurkholder Thank you for your response. That issue occurred after I tried to install completion for git in .bashrc. Perhaps you are right: recently after reinstalling the OS, I found git completion works by default without any scripts in .bashrc. But in that time I used the script for completion. That's why I wrote about it here. Dec 11, 2017 at 18:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .