apjanke / dotfiles

apjanke's configuration files and system setup scripts
Other
14 stars 1 forks source link

Buncha "have: command not found" errors in bash #10

Open apjanke opened 9 months ago

apjanke commented 9 months ago

For the last week or so, when I fire up bash from inside a zsh session inside a Mac terminal (iTerm2) using these dotfiles, I get a bunch of error messages like "bash: have: command not found".

I don't know what would be calling have; I don't seem to be doing so inside my bashy dotfiles here.

Maybe it's some bash completion thing? https://stackoverflow.com/questions/12874920/have-keyword-for-bash-completion

Symptoms

🎊  janke@ (base) ~ 
î‚° î‚° bash
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
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
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
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
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
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: /usr/local/etc/bash_completion.d/cvs: line 20: syntax error near unexpected token `('
bash: /usr/local/etc/bash_completion.d/cvs: line 20: `        COMPREPLY=( $( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ) )'
bash: /usr/local/etc/bash_completion.d/cvs: line 21: syntax error near unexpected token `else'
bash: /usr/local/etc/bash_completion.d/cvs: line 21: `    else'
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
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
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
bash: have: command not found
bash: /usr/local/etc/bash_completion.d/dvd+rw-tools: line 19: syntax error near unexpected token `('
bash: /usr/local/etc/bash_completion.d/dvd+rw-tools: line 19: `        /?(r)dev/*)'
bash: have: command not found
bash: have: command not found

No idea what's going on here. I don't see any have calls in my dotfiles.

This is on at least angharad, my macOS 14.2.1 iMac on Intel Mac.

TODO

apjanke commented 9 months ago

Oh, yeah, this looks completion-related. I uninstalled bash from Homebrew and MacPorts on this box, and then re-installed bash-completion on both of them, and now the errors have changed and are saying more stuff about completion.

Maybe this is a problem with both MacPorts and Homebrew trying to control files in the main /etc dir?

image
aredridel commented 9 months ago

Almost certainly completion:

homebrew/etc/bash_completion.d on î‚  master (302e83e9a)
:; grep have * | more
grep: helpers: Is a directory
abook:have abook &&
ant:have ant &&
ant:have complete-ant-cmd.pl && \
apache2ctl:have apache2ctl && {
apt:have apt-get &&
apt:have apt-cache &&
apt-build:have apt-build &&
aptitude:have aptitude && {
aptitude:have grep-status && {

etc

aredridel commented 9 months ago

have is defined by homebrew/etc/bash-completion (not .d):

have()
{
    unset -v have
    # Completions for system administrator commands are installed as well in
    # case completion is attempted via `sudo command ...'.
    PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null &&
    have="yes"
}
aredridel commented 9 months ago

Certainly mixing macports and homebrew is weird, and might introduce conflicts since neither is reconciling with the other, but I don't know of any specific conflict offhand.

apjanke commented 9 months ago

Ah, good catch. I did a brew rm bash-completion and the errors went away.

I've got an oddball system here, and it's probably due to that: up until recently, I was a macOS 10.14 Mojave holdout, and thinking about migrationg Octave.app to MacPorts, so running MacPorts for the last couple years, and then recently added Homebrew back in. And set up these dotfiles to conditionally load them, but seems like you can't easily fully conditionalize loading in MacPorts. Or, more likely, I'm just doing it wrong.

I think I'll prolly just uninstall MacPorts here, and stick to one or the other of it or Homebrew on each machine.

Thanks, @aredridel!