There are older versions of Google Cloud Platform tools: Docker
Asked Answered
Y

5

12

After updating gcloud I get this warning, but how do I do it(Should I remove Docker)?

WARNING:   There are older versions of Google Cloud Platform tools on your system PATH.
  Please remove the following to avoid accidentally invoking these old tools:

  /Applications/Docker.app/Contents/Resources/bin/kubectl

I have this in my .zshrc:

# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/<NAME>/google-cloud-sdk/path.zsh.inc' ]; then source '/Users/<NAME>/google-cloud-sdk/path.zsh.inc'; fi

# The next line enables shell command completion for gcloud.
if [ -f '/Users/<NAME>/google-cloud-sdk/completion.zsh.inc' ]; then source '/Users/<NAME>/google-cloud-sdk/completion.zsh.inc'; fi

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
Yemane answered 3/12, 2018 at 15:58 Comment(0)
L
15

This happens because docker-for-mac installs a bin for kubectl, and gcloud-sdk also installs another bin with gcloud components install kubectl.

My recommendation is to uninstall kubectl as component from gcloud, overwrite the symlink from docker-for-mac, and only use the homebrew installed bin.

Try this commands:

gcloud components remove kubectl

brew install kubernetes-cli

brew link --overwrite kubernetes-cli

Lysias answered 7/1, 2019 at 18:55 Comment(1)
On my MacOS Mojave, when I do which kubectl it points to kubectl from the google-cloud-sdk. To me the warning is extraneous and can therefore be ignored.Had
L
17

TLDR

/usr/local/bin/kubectl is a link installed by Docker: ls -l /usr/local/bin/kubectl => /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl. Removing the link has no side effects and solves the conflict:

rm /usr/local/bin/kubectl

Justification

The conflict is with the Docker-provided version of kubectl so it makes sense to check what Docker docs have to say about it. https://docs.docker.com/desktop/kubernetes/#use-the-kubectl-command

Extract:

If you installed kubectl using Homebrew, or by some other method, and experience conflicts, remove /usr/local/bin/kubectl.

Lennon answered 7/9, 2019 at 14:0 Comment(0)
L
15

This happens because docker-for-mac installs a bin for kubectl, and gcloud-sdk also installs another bin with gcloud components install kubectl.

My recommendation is to uninstall kubectl as component from gcloud, overwrite the symlink from docker-for-mac, and only use the homebrew installed bin.

Try this commands:

gcloud components remove kubectl

brew install kubernetes-cli

brew link --overwrite kubernetes-cli

Lysias answered 7/1, 2019 at 18:55 Comment(1)
On my MacOS Mojave, when I do which kubectl it points to kubectl from the google-cloud-sdk. To me the warning is extraneous and can therefore be ignored.Had
D
1

Here is my case you can refer to. After running gcloud components update, I got this warning:

WARNING: There are older versions of Google Cloud Platform tools on your system PATH. Please remove the following to avoid accidentally invoking these old tools:

/usr/local/Cellar/kubernetes-cli/1.10.2/bin/kubectl

I check this tool using brew list

☁  issue [master] brew list
coreutils       gdbm            git-lfs         icu4c           kops            kubectx         libpng          mtr             openssl         python@2        sqlite          tree            wxmac
erlang          geoip           git-redate      jpeg            kube-ps1        kubernetes-cli  libtiff         node            pcre            readline        telnet          watchman

After reading the doc. I decided to uninstall kubernetes-cli and its dependencies kops, kube-ps1, and kubectx to avoid the conflicts.

☁  issue [master] brew uninstall kops kube-ps1 kubectx
Uninstalling /usr/local/Cellar/kops/1.9.0... (5 files, 129.8MB)
Uninstalling /usr/local/Cellar/kube-ps1/0.6.0... (6 files, 29.0KB)
Uninstalling /usr/local/Cellar/kubectx/0.5.0... (12 files, 27.8KB)
☁  issue [master] brew uninstall kubernetes-cli
Uninstalling /usr/local/Cellar/kubernetes-cli/1.10.2... (178 files, 52.8MB)
☁  issue [master] gcloud components update

All components are up to date.

This warning is gone.

Decurrent answered 25/1, 2019 at 2:30 Comment(0)
A
0

I just went into the Docker file's bin folder and moved the kubectl to the trash.

Albina answered 16/7, 2019 at 7:55 Comment(0)
P
0

Do echo $PATH and check which folder takes precedence. In my case it is like .../Users/myname/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:.... Here the kubectl in gcloud is actually before the kubectl from Docker Desktop (which is in /usr/local/bin/kubectl) so there is no problem. If this is also your case you don't need to do anything.

Of course, if you want to completely remove confusion you can just delete the link /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl, or rename it.

Update:

In the recent docker desktop releases they actually provided another link /usr/local/bin/kubectl.docker -> /Applications/Docker.app/Contents/Resources/bin/kubectl to differentiate it from other kubectl so it is not a bad idea to just simply delete the link /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl

Prenotion answered 15/8, 2022 at 17:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.