bash_completion causing a 'command not found' in terminal
Asked Answered
T

1

7

I'm using bash_completion in order to hit tab and see branch names and directories. That all works. I placed this into my bash_profile in order to connect bash_completion:

if [ -f `brew --prefix`/etc/bash_completion ]; then
    . `brew --prefix`/etc/bash_completion
fi

When I start my terminal now I get:

-bash: @MyNameHERE: command not found

If I remove the first snippet from the bash_profile, this goes away, but then bash_completion doesn't work. Any thoughts?

Brew Doctor results:

Please note that these warnings are just used to help the Homebrew  maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry and just ignore them. Thanks!

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
    /usr/local/include/node/android-ifaddrs.h
    /usr/local/include/node/ares.h
    /usr/local/include/node/ares_version.h
    /usr/local/include/node/libplatform/libplatform.h
    /usr/local/include/node/nameser.h
    /usr/local/include/node/node.h
    /usr/local/include/node/node_buffer.h
    /usr/local/include/node/node_internals.h
    /usr/local/include/node/node_object_wrap.h
    /usr/local/include/node/node_version.h
    /usr/local/include/node/openssl/aes.h
    /usr/local/include/node/openssl/archs/aix-gcc/opensslconf.h
    /usr/local/include/node/openssl/archs/aix64-gcc/opensslconf.h
    /usr/local/include/node/openssl/archs/BSD-x86/opensslconf.h
    /usr/local/include/node/openssl/archs/BSD-x86_64/opensslconf.h
    /usr/local/include/node/openssl/archs/darwin-i386-cc/opensslconf.h
    /usr/local/include/node/openssl/archs/darwin64-x86_64-cc/opensslconf.h
    /usr/local/include/node/openssl/archs/linux-aarch64/opensslconf.h
    /usr/local/include/node/openssl/archs/linux-armv4/opensslconf.h
    /usr/local/include/node/openssl/archs/linux-elf/opensslconf.h
    /usr/local/include/node/openssl/archs/linux-ppc/opensslconf.h
    /usr/local/include/node/openssl/archs/linux-ppc64/opensslconf.h
    /usr/local/include/node/openssl/archs/linux-x32/opensslconf.h
    /usr/local/include/node/openssl/archs/linux-x86_64/opensslconf.h
    /usr/local/include/node/openssl/archs/solaris-x86-gcc/opensslconf.h
    /usr/local/include/node/openssl/archs/solaris64-x86_64-gcc/opensslconf.h
    /usr/local/include/node/openssl/archs/VC-WIN32/opensslconf.h
    /usr/local/include/node/openssl/archs/VC-WIN64A/opensslconf.h
    /usr/local/include/node/openssl/asn1.h
    /usr/local/include/node/openssl/asn1_mac.h
    /usr/local/include/node/openssl/asn1t.h
    /usr/local/include/node/openssl/bio.h
    /usr/local/include/node/openssl/blowfish.h
    /usr/local/include/node/openssl/bn.h
    /usr/local/include/node/openssl/buffer.h
    /usr/local/include/node/openssl/camellia.h
    /usr/local/include/node/openssl/cast.h
    /usr/local/include/node/openssl/cmac.h
    /usr/local/include/node/openssl/cms.h
    /usr/local/include/node/openssl/comp.h
    /usr/local/include/node/openssl/conf.h
    /usr/local/include/node/openssl/conf_api.h
    /usr/local/include/node/openssl/crypto.h
    /usr/local/include/node/openssl/des.h
    /usr/local/include/node/openssl/des_old.h
    /usr/local/include/node/openssl/dh.h
    /usr/local/include/node/openssl/dsa.h
    /usr/local/include/node/openssl/dso.h
    /usr/local/include/node/openssl/dtls1.h
    /usr/local/include/node/openssl/e_os2.h
    /usr/local/include/node/openssl/ebcdic.h
    /usr/local/include/node/openssl/ec.h
    /usr/local/include/node/openssl/ecdh.h
    /usr/local/include/node/openssl/ecdsa.h
    /usr/local/include/node/openssl/engine.h
    /usr/local/include/node/openssl/err.h
    /usr/local/include/node/openssl/evp.h
    /usr/local/include/node/openssl/hmac.h
    /usr/local/include/node/openssl/idea.h
    /usr/local/include/node/openssl/krb5_asn.h
    /usr/local/include/node/openssl/kssl.h
    /usr/local/include/node/openssl/lhash.h
    /usr/local/include/node/openssl/md4.h
    /usr/local/include/node/openssl/md5.h
    /usr/local/include/node/openssl/mdc2.h
    /usr/local/include/node/openssl/modes.h
    /usr/local/include/node/openssl/obj_mac.h
    /usr/local/include/node/openssl/objects.h
    /usr/local/include/node/openssl/ocsp.h
    /usr/local/include/node/openssl/opensslconf.h
    /usr/local/include/node/openssl/opensslv.h
    /usr/local/include/node/openssl/ossl_typ.h
    /usr/local/include/node/openssl/pem.h
    /usr/local/include/node/openssl/pem2.h
    /usr/local/include/node/openssl/pkcs12.h
    /usr/local/include/node/openssl/pkcs7.h
    /usr/local/include/node/openssl/pqueue.h
    /usr/local/include/node/openssl/rand.h
    /usr/local/include/node/openssl/rc2.h
    /usr/local/include/node/openssl/rc4.h
    /usr/local/include/node/openssl/ripemd.h
    /usr/local/include/node/openssl/rsa.h
    /usr/local/include/node/openssl/safestack.h
    /usr/local/include/node/openssl/seed.h
    /usr/local/include/node/openssl/sha.h
    /usr/local/include/node/openssl/srp.h
    /usr/local/include/node/openssl/srtp.h
    /usr/local/include/node/openssl/ssl.h
    /usr/local/include/node/openssl/ssl2.h
    /usr/local/include/node/openssl/ssl23.h
    /usr/local/include/node/openssl/ssl3.h
    /usr/local/include/node/openssl/stack.h
    /usr/local/include/node/openssl/symhacks.h
    /usr/local/include/node/openssl/tls1.h
    /usr/local/include/node/openssl/ts.h
    /usr/local/include/node/openssl/txt_db.h
    /usr/local/include/node/openssl/ui.h
    /usr/local/include/node/openssl/ui_compat.h
    /usr/local/include/node/openssl/whrlpool.h
    /usr/local/include/node/openssl/x509.h
    /usr/local/include/node/openssl/x509_vfy.h
    /usr/local/include/node/openssl/x509v3.h
    /usr/local/include/node/pthread-fixes.h
    /usr/local/include/node/stdint-msvc2008.h
    /usr/local/include/node/tree.h
    /usr/local/include/node/uv-aix.h
    /usr/local/include/node/uv-bsd.h
    /usr/local/include/node/uv-darwin.h
    /usr/local/include/node/uv-errno.h
    /usr/local/include/node/uv-linux.h
    /usr/local/include/node/uv-sunos.h
    /usr/local/include/node/uv-threadpool.h
    /usr/local/include/node/uv-unix.h
    /usr/local/include/node/uv-version.h
    /usr/local/include/node/uv-win.h
    /usr/local/include/node/uv.h
    /usr/local/include/node/v8-debug.h
    /usr/local/include/node/v8-platform.h
    /usr/local/include/node/v8-profiler.h
    /usr/local/include/node/v8-testing.h
    /usr/local/include/node/v8-util.h
    /usr/local/include/node/v8-version.h
    /usr/local/include/node/v8.h
    /usr/local/include/node/v8config.h
    /usr/local/include/node/zconf.h
    /usr/local/include/node/zlib.h

Set -xv Results:

https://raw.githubusercontent.com/SpencerRohan/debug/master/README.md

Thermosphere answered 1/2, 2016 at 15:18 Comment(18)
Can you update your question with the exact output of brew doctor? (If that leads you to a solution, post that as an answer and accept it.)Siphonostele
@Siphonostele brew doctor results are posted. I updated and fixed a path issue by running: echo export PATH="/usr/local/bin:$PATH" >> ~/.bash_profile Problem still occuringThermosphere
If your problem is related with your ~/.bash_profile file, then try to debug it: insert this line to the beginning of the file: set -xvStratocumulus
What happens when you run: . brew --prefix/etc/bash_completion` on its own?Siphonostele
@Siphonostele :No such file or directory. If I run brew --prefix alone I get /usr/localThermosphere
So you have no /usr/local/etc/bash_completion folder on your system? I assume you brew install bash-completion and brew tap homebrew/completions successfully ?Siphonostele
bash_completion is a file, at that directory - I believe I successfully installed the above.Thermosphere
As a start try this: which brewStratocumulus
@Zsigmond Lőrinczy /usr/local/bin/brewThermosphere
Then adding '/usr/local/bin' into the PATH should have helped. You still could try to debug with command set -xvStratocumulus
@ZsigmondLőrinczyWhat am I looking for in the debug command?Thermosphere
Just quote here (copy+paste) the output you got.Zohar
@LorinczyZsigmond Code results have been added above - thanksThermosphere
@ZsigmondLőrinczy Code results have been added above - thanksThermosphere
That's cool, but it's tons of lines. You should cut out everything from your .bash_profile (make a backup copy beforehand) that is unrelated the current problem.Stratocumulus
The only thing remotely like that is a directory called /usr/local/etc/bash_completion.d so your if statement is plainly wrong. Inside that directory are symlinks for npm, tmux and a couple of others. I suspect homebrew has been updated with further flexibility that your script doesn't take account of...Flyweight
@MarkSetchell github.com/bobthecow/git-flow-completion/wiki/… -- that if statement was grabbed from here. Not saying you are incorrect, but just following directionsThermosphere
I've updated to GNU bash version 4.3.42 - and upgraded bash-completion to bash-completion2. Still having the same issue.Thermosphere
D
2

This:

-bash: @MyNameHERE: command not found

is telling you it is trying to execute the command @MyNameHERE and it doesn't find it in your system.

Try replacing:

if [ -f `brew --prefix`/etc/bash_completion ]; then
    . `brew --prefix`/etc/bash_completion
fi

with

brewPrefix=`brew --prefix`
if [ -f "${brewPrefix}/etc/bash_completion" ]; then
    . "${brewPrefix}/etc/bash_completion"
fi

my wild guess is that some space in the return value of brew --prefix can cause this

if this still doesn't work try setting the full path in the brewPrefix variable (comment the other line with a #). the execution in .bash_profile sometimes do not work like executing it in your usual terminal because environment variables are different

Also make sure that snippet is placed at the BOTTOM of the .bash_profile

Dinge answered 21/3, 2016 at 18:4 Comment(3)
Replaced the code snippet and it worked like a charm. No full path needed. Also, placed at the bottom of the .bash_profile -- however it worked when it was not at the bottom.Thermosphere
Then the issue was 99% a space in the path :)Dinge
The variable isn't necessary, as long as the output of brew --prefix is quoted. (if [ -f "$(brew --prefix)"/etc/bash_completion ], for example. Also, prefer $(...) over backquotes.)Joktan

© 2022 - 2024 — McMap. All rights reserved.