Hey you! I hope you are having a wonderful day π
The intention of these words is to document the installation of the Google Cloud CLI on macOS, that for me was an adventure.
While I was working on the installation, I found documentation in various places, as well as responses to problems in other places, and hmmm, I guess this will be another one of those places π€
Aaaanyways, the idea is to document what worked for me π«ΆπΌ and hopefully it will help another Earthling π
Notes
The version of macOS used for the installation is: macOS Monterrey -version 12.6.6
and platform is macOS 64-bit (x86_64)
.
The same worked for macOS Ventura - version 13.4
and platform macOS 64-bit (ARM64, Apple M1 silicon)
.
First: brew
The Package Manager for macOS that I used is brew
.
So, assuming that you are using brew
, before you go on with everything, I recommend to run the following:
|
|
Second: python
The Google Cloud CLI uses python, and so the version of python
installed on your host is
very important. What I found is that if the right version of python
is not installed and setup in the host,
the Network diagnostic will fail.
This means that after running the gcloud info --run-diagnostics
command, and waiting for
Checking network connection...β Ά
…, there will be an error message like the following:
|
|
How did I install Python?
First, I had to uninstall almost all the python
and pip
versions in the macOS host, and only leave the
python
and pip
at /usr/bin/
.
I also uninstalled pyenv
and the python
versions that were installed via pyenv
.
βΉοΈ If you had versions of Python installed with brew
make sure that you run brew cleanup
after you uninstall them.
Then I installed python 3.9.2
. The installation of this version of python
, I did it with asdf
.
You can find the instructions on how to install asdf
here.
After asdf
was installed, I installed python
with:
|
|
β¨ python 3.9.2
β¨ is the version that magically worked.
To test that you are using this installation python
you can run whereis python
in your terminal, and make sure that it refers
to the path where asdf
installed python
.
You can also run: python -V
and check that output is: Python 3.9.2
.
Third: The Google Cloud CLI
Installation
I used the Google Cloud CLI installer instead of the recommended installation, since it provided more interactivity, it did all it needed to do, and well, it worked π :
|
|
When prompted if you want to install Python, say n
:
|
|
Diagnostics
After the installation is finished, run:
|
|
This step, when it worked, it took 1 second to output something like:
|
|
π #Fiesta π
If the command takes more than 3 minutes to return, there probably will be a problem, and I would recommend to stop and:
- Uninstall the Google Cloud CLI.
- Restart the host.
- Try the Installation again.
Init
After the diagnostics succeed, you can run gcloud init --console-only
.
This will run the Network diagnostic again, but since we already tested it in the previous step (Diagnostics),
it should take less than 5 seconds and output something like the following:
|
|
Then you will be asked to log in with your Google account.
Go through the steps, to authorize the Google Cloud CLI to use your Google Account for authentication, select a project, and at the end you will see a message like the following:
|
|
Next, take a look into the gcloud CLI cheat sheet and have fun!
Happy coding, testing, and cloud’ing! β¨