kubernetes-sigs/krew

Install succeeds but 'Error: unknown command "krew" for "kubectl"' WSL Ubuntu

ma53 opened this issue · 9 comments

ma53 commented

I'm not sure what I'm missing. The install seems to work fine:

~
▶ (
  set -x; cd "$(mktemp -d)" &&
  OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
  ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
  KREW="krew-${OS}_${ARCH}" &&
  curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
  tar zxvf "${KREW}.tar.gz" &&
  ./"${KREW}" install krew
)
+-zsh:31> mktemp -d
+-zsh:31> cd /tmp/tmp.O6NSzUaAyV
+-zsh:32> OS=+-zsh:32> uname
+-zsh:32> OS=+-zsh:32> tr '[:upper:]' '[:lower:]'
+-zsh:32> OS=linux
+-zsh:33> ARCH=+-zsh:33> uname -m
+-zsh:33> ARCH=+-zsh:33> sed -e s/x86_64/amd64/ -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/'
+-zsh:33> ARCH=amd64
+-zsh:34> KREW=krew-linux_amd64
+-zsh:35> curl -fsSLO https://github.com/kubernetes-sigs/krew/releases/latest/download/krew-linux_amd64.tar.gz
+-zsh:36> tar zxvf krew-linux_amd64.tar.gz
./LICENSE
./krew-linux_amd64
+-zsh:37> ./krew-linux_amd64 install krew
Adding "default" plugin index from https://github.com/kubernetes-sigs/krew-index.git.
Updated the local copy of plugin index.
Installing plugin: krew
Installed plugin: krew
\
 | Use this plugin:
 |      kubectl krew
 | Documentation:
 |      https://krew.sigs.k8s.io/
 | Caveats:
 | \
 |  | krew is now installed! To start using kubectl plugins, you need to add
 |  | krew's installation directory to your PATH:
 |  |
 |  |   * macOS/Linux:
 |  |     - Add the following to your ~/.bashrc or ~/.zshrc:
 |  |         export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
 |  |     - Restart your shell.
 |  |
 |  |   * Windows: Add %USERPROFILE%\.krew\bin to your PATH environment variable
 |  |
 |  | To list krew commands and to get help, run:
 |  |   $ kubectl krew
 |  | For a full list of available plugins, run:
 |  |   $ kubectl krew search
 |  |
 |  | You can find documentation at
 |  |   https://krew.sigs.k8s.io/docs/user-guide/quickstart/.
 | /
/

I've added Krew to my Path and verified that it's there (actual value of PATH truncated by me):

~
▶ cat ~/.zshrc | grep krew
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"

~
▶ echo $PATH
/home/tim/.krew/bin

~
▶ ls /home/tim/.krew/bin
kubectl-krew

And yet:

~
▶ kubectl krew
Error: unknown command "krew" for "kubectl"
Run 'kubectl --help' for usage.

I started with kubectl 1.25 and even tried downgrading to 1.12.10, still no dice. Any thoughts?

Have you restarted your shell?

Try "where kubectl-krew". Nothing else stands out to me from the logs and I used krew on WSL too.

ma53 commented

Yeah I've restarted my shell plenty. The shell itself knows where kubectl-krew is, it's just that kubectl doesn't know what kubectl krew is:

▶ where kubectl-krew
/home/tim/.krew/bin/kubectl-krew

▶ kubectl krew
Error: unknown command "krew" for "kubectl"
Run 'kubectl --help' for usage.

Whats the output of "kubectl plugins list"?

ma53 commented
▶ kubectl plugins list
Error: unknown command "plugins" for "kubectl"

Did you mean this?
        plugin

Run 'kubectl --help' for usage.

▶ kubectl plugin list
error: no plugins installed.

I'm afraid your issue is with the kubectl repo.
/close

@ahmetb: Closing this issue.

In response to this:

I'm afraid your issue is with the kubectl repo.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

ma53 commented

@ahmetb Could you please elaborate? What about my situation indicates to you that Kubectl is the problem?

If kubectl-krew is in your PATH and it's an executable, it should show up in kubectl plugin list. If not, it's a kubectl issue. Try installing a random kubectl plugin manually, without krew, to see it shows up.

ma53 commented

In case anyone finds themselves here with a similar issue, here's how it turned out for me.

I had been using apt to install kubectl, and while kubectl itself functioned properly, something about it wasn't playing nice with krew. I uninstalled kubectl through apt and then downloaded it directly from Kubernetes: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/

After that, everything worked fine. I didn't even have to reinstall krew.