Rakib
Rakib

Reputation: 13085

Use `kubectl` from "asdf" instead of "homebrew"

I have had kubectl installed from homebrew in mac since a long time. So from my path, the homebrew kubectl is used.

Today I installed kubectl using asdf to be able to use different versions of kubectl for different projects. However, my mac still sees the kubectl path from my homebrew installation - not the one from my new asdf installation.

How do I run the kubectl command and make it use the asdf version instead of using the homebrew version ?

Upvotes: 2

Views: 3327

Answers (1)

Rakib
Rakib

Reputation: 13085

UPDATED ANSWER:

Added the following line into my ~/.zshrc file

echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc

Source: http://asdf-vm.com/guide/getting-started.html#_3-install-asdf


OLD ANSWER BELOW

Asked too soon. Searched a bit more and found this blog which helped. https://migueldavid.eu/using-multiple-versions-of-kubectl-on-macos

The ASDF installations are made available through the ~/.asdf/shims folder. As long as this directory is added into your $PATH, and as long as this path comes BEFORE the others, it will respect the installations via ASDF (if any) before the installations via Homebrew.

I added the following line in my ~/.zshrc file

export PATH=$HOME/.asdf/shims:$PATH

Upvotes: 7

Related Questions