Minikube: Bash completion not working (macOS Sierra, minikube 0.12.2, drive xhyve)

Created on 23 Nov 2016  路  5Comments  路  Source: kubernetes/minikube

Hi

Bash completion isn't working for me.

I have bash completion working for git, gcloud and kubectl, which makes me think it's not something on my end - so thought I'd post the issue.

I've installed bash-completion using homebrew. My ~/.bash_profile is below. I've also tried restarting my terminal, sourcing the bash profile, and also running "source <(minikube completion bash)" directly.

I'm new to bash completion so not sure how to provide you with a log or anything else useful.

#bash completion
if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

#source kubectl bash completion
source <(kubectl completion bash)

#source minikube bash completion
source <(minikube completion bash)

minikube version: v0.12.2
macOS Sierra
"DriverName": "xhyve"
Docker version 1.12.3, build 6b644ec

kinbug omacos

Most helpful comment

Thanks for catching this. Looks like this particular method is not working on macOS.

After some digging I found http://unix.stackexchange.com/a/174366

Seems like process substitution doesn't work like this on the versions of bash that ship with macOS.

source <(kubectl completion bash) source <(minikube completion bash) don't work for me on El Capitan. This is the version of bash I have on my mac.

-> bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.

Solution
For now, you can just save the output to a file and source that in your bashrc.

Something like

minikube completion bash > ~/.minikube-completion

Then in your ~/.bash_profile

source ~/.minikube-completion

I'll update the docs here and upstream to reflect the behavior on mac.

All 5 comments

@r2d4 any ideas?

Thanks for catching this. Looks like this particular method is not working on macOS.

After some digging I found http://unix.stackexchange.com/a/174366

Seems like process substitution doesn't work like this on the versions of bash that ship with macOS.

source <(kubectl completion bash) source <(minikube completion bash) don't work for me on El Capitan. This is the version of bash I have on my mac.

-> bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.

Solution
For now, you can just save the output to a file and source that in your bashrc.

Something like

minikube completion bash > ~/.minikube-completion

Then in your ~/.bash_profile

source ~/.minikube-completion

I'll update the docs here and upstream to reflect the behavior on mac.

Hi thanks for looking into this.

I can confirm that that does indeed work. Thanks.

Although to be fair, bash completion is working fine for kubectl for me using "source <(kubectl completion bash)" so it's strange it's not working. My version of bash is:

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc. 

FWIW eval "$(minikube completion bash)" works; some may not like the use of eval... but you guys are trustworthy, right?

I would have expected source minikube completion bash to do the trick too, but running that kills my terminal session - probably an exit in there somewhere, where there should be a return.

I'm guessing the source <(minikube completion bash) process substitution does not work as source <filename> <arguments> is looking for a <filename> to execute (it will look on the PATH to find it, under normal conditions), not lines (of bash) to read in as input (which eval does happily) - imagine if <filename> was a binary command and not a (text) shell script.

I had similar issue - I have installed bash-completion brew install bash-completion

  • I went to dir /usr/local/etc/bash_completion.d
  • created the minikube completion file minikube completion bash > minikube in that directory
  • (dont forget to create a new terminal instance after this step)

minikube autocompletion works from there on

Was this page helpful?
0 / 5 - 0 ratings