If you were to attempt to install google-cloud-sdk
natively (via Homebrew) on Apple Silicon, you'd get the following error:
$ brew install --cask google-cloud-sdk
# etc...
==> Installing Cask google-cloud-sdk
Beginning update. This process may take several minutes.
ERROR: (gcloud.components.update) The following components are unknown [kuberun, anthoscli].
==> Purging files for version latest of Cask google-cloud-sdk
# etc...
The general consensus points to running gcloud
under Rosetta 2 for now (Example StackOverflow comment). However, thanks to this particular comment on Reddit, I've been able to get google-cloud-sdk
working just fine! The trick is to just modify the install script for google-cloud-sdk
. To do this, you'll want to run:
$ brew edit --cask google-cloud-sdk
The default content should be something like this:
cask "google-cloud-sdk" do
# etc...
postflight do
system_command "#{staged_path}/#{token}/install.sh",
args: [
"--usage-reporting", "false", "--bash-completion", "false", "--path-update", "false",
"--rc-path", "false", "--quiet"
],
env: { "CLOUDSDK_PYTHON" => Formula["python"].opt_bin/"python3" }
end
# etc...
end
What you'll want to do here is append the arguments --override-components core
to the system_command
directive, like so:
18c18
< "--rc-path", "false", "--quiet"
---
> "--rc-path", "false", "--quiet", "--override-components", "core"
After this, gcloud
should have installed perfectly! 🥳 Assuming of course that you have sourced the path.zsh.inc
& completion.zsh.inc
files as prompted by the brew
command.
You can investigate additional components that can be installed by running gcloud components list
:
????????????????????????????????????????????????????????????????????????????????????????????????????????
? Components ?
????????????????????????????????????????????????????????????????????????????????????????????????????????
? Status ? Name ? ID ? Size ?
????????????????????????????????????????????????????????????????????????????????????????????????????????
? Not Installed ? BigQuery Command Line Tool ? bq ? < 1 MiB ?
? Not Installed ? Cloud Datalab Command Line Tool ? datalab ? < 1 MiB ?
? Not Installed ? Cloud Datastore Emulator ? cloud-datastore-emulator ? 18.4 MiB ?
? Not Installed ? Cloud Firestore Emulator ? cloud-firestore-emulator ? 41.5 MiB ?
? Not Installed ? Cloud Pub/Sub Emulator ? pubsub-emulator ? 56.4 MiB ?
? Not Installed ? gcloud Alpha Commands ? alpha ? < 1 MiB ?
? Not Installed ? gcloud Beta Commands ? beta ? < 1 MiB ?
? Not Installed ? gcloud app Java Extensions ? app-engine-java ? 59.6 MiB ?
? Not Installed ? gcloud app PHP Extensions ? app-engine-php ? 21.9 MiB ?
? Not Installed ? gcloud app Python Extensions ? app-engine-python ? 6.1 MiB ?
? Not Installed ? gcloud app Python Extensions (Extra Libraries) ? app-engine-python-extras ? 27.1 MiB ?
? Not Installed ? kubectl ? kubectl ? < 1 MiB ?
? Not Installed ? pkg ? pkg ? ?
? Installed ? Cloud SDK Core Libraries ? core ? 16.1 MiB ?
? Installed ? Cloud Storage Command Line Tool ? gsutil ? 3.5 MiB ?
????????????????????????????????????????????????????????????????????????????????????????????????????????
In my case, I was able to install the gsutil
component by running gcloud components install gsutil
. Additional components will be subject to it working for Apple Silicon for now until a supported update becomes available.