Emulator for Google Cloud Run won't start on M1 Mac

Viewed 639

I'm attempting to run the command gcloud beta code dev to launch the Cloud Run emulator, but it won't start with a skaffold error.

I've tried running this both locally (M1 Mac) and in the Cloud Shell.

The information below is all from the Cloud Shell attempt, since (1) that's reproducible for everyone, and (2), running the emulator from the Cloud Shell worked for me initially, whereas local never did.

I reset the Virtual Machine to a clean state, just to make sure, but it still errors.

Cloud Shell gloud --version info

Google Cloud SDK 365.0.1
alpha 2021.11.19
app-engine-go 1.9.71
app-engine-java 1.9.92
app-engine-python 1.9.97
app-engine-python-extras 1.9.96
beta 2021.11.19
bigtable
bq 2.0.71
cbt 0.10.1
cloud-build-local 0.5.2
cloud-datastore-emulator 2.1.0
core 2021.11.19
datalab 20190610
gsutil 5.5
kind 0.7.0
kpt 1.0.0-beta.7
local-extract 1.3.1
minikube 1.23.2
pubsub-emulator 0.6.0
skaffold 1.34.0

End of gcloud beta code dev --verbosity=debug log. The entire log is extremely long. This section seemed the most relevant, but if useful I can post the whole thing.

Flag --enable-rpc has been deprecated, flags --rpc-port or --rpc-http-port now imply --enable-rpc=true, so please use only those instead
INFO[0000] Activated kube-context "gcloud-local-dev"     subtask=-1 task=DevLoop
INFO[0000] starting gRPC server on port 33491            subtask=-1 task=DevLoop
INFO[0000] starting gRPC HTTP server on port 20201 (proxying to 33491)  subtask=-1 task=DevLoop
INFO[0000] Skaffold &{Version:v1.34.0 ConfigVersion:skaffold/v2beta25 GitVersion: GitCommit:22cfab75ffb305e7af220910af2f48d0a5c0e6af BuildDate:2021-10-27T00:27:04Z GoVersion:go1.14.14 Compiler:gc Platform:linux/amd64 User:}  subtask=-1 task=DevLoop
INFO[0000] Loaded Skaffold defaults from "/home/username/.skaffold/config"  subtask=-1 task=DevLoop
DEBU[0000] config version out of date: upgrading to latest "skaffold/v2beta25"  subtask=-1 task=DevLoop
DEBU[0000] parsed 1 configs from configuration file /tmp/skaffold_zwl932r1.yaml  subtask=-1 task=DevLoop
DEBU[0000] Running command: [tput colors]                subtask=-1 task=DevLoop
DEBU[0000] Command output: [8
]                          subtask=-1 task=DevLoop
invalid skaffold config: source: /tmp/skaffold_zwl932r1.yaml, in unnamed config at index 0: invalid image "google cloud run": invalid reference format

In case it matters, here's the contents of the directory in which I'm running gcloud beta code dev

Dockerfile
index.js
package.json
/Assets 

And this folder (1) successfully deploys from source to Google Cloud Run and (2) worked yesterday with the local emulator.

What stands out to me is "invalid image: google cloud run." "Google cloud run" is the name of the folder I'm in, but it shouldn't be the image name...

I'm happy to help you help me -- just tell me what other info you need.

1 Answers

I've found an interim solution that works great, which is to use https://shell.cloud.google.com/ which has glcoud preinstalled with all dependencies.

EDIT: The emulator in Cloud Shell sometimes mysteriously doesn't work (see edited question above). However, I've had consistent success in a GitHub Codespace, opening a blank/default Codespace and following the Linux installation instructions in the docs https://cloud.google.com/run/docs/testing/local#cloud-code-emulator Once the Codespace is configured, it stays configured when you come back to it, so it works as a persistent "local" testing environment for Google Cloud Run.

This allows for "local" testing of a Cloud Run container in the sense that you don't need to actually deploy (you can see logs in the terminal, and your container on localhost) -- and everything just works out of the box.

Of course, it's ironic that to do local testing, you need to use a cloud shell!

Related