{"record":{"id":"d877acc6f2d471f7","repo":"GoogleContainerTools/skaffold","slug":"port-forward-run-gcloud-not-found","errorCode":"PORT_FORWARD_RUN_GCLOUD_NOT_FOUND","errorMessage":"gcloud not found","messagePattern":"gcloud not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/deploy/cloudrun/accessor.go","lineNumber":146,"sourceCode":"func (r *RunAccessor) Stop() {\n\tfor _, forwarder := range r.forwarders {\n\t\tforwarder.Stop()\n\t}\n}\n\nfunc findGcloud() bool {\n\tcmd := exec.Command(\"gcloud\", \"--version\")\n\treturn cmd.Run() == nil\n}\n\ntype runProxyForwarder struct {\n\tresources *resourceTracker\n}\n\nfunc (r *runProxyForwarder) Start(ctx context.Context, out io.Writer) error {\n\tif !gcloudInstalled() {\n\t\toutput.Red.Fprintln(out, \"gcloud not found on path. Unable to set up Cloud Run port forwarding\")\n\t\treturn sErrors.NewError(fmt.Errorf(\"gcloud not found\"), &proto.ActionableErr{ErrCode: proto.StatusCode_PORT_FORWARD_RUN_GCLOUD_NOT_FOUND})\n\t}\n\tif r.resources.resources == nil {\n\t\t// no forwards configured\n\t\treturn nil\n\t}\n\tfor _, resource := range r.resources.resources {\n\t\tif resource.port == 0 {\n\t\t\tport := retrieveAvailablePort(\"localhost\", 8080, r.resources.forwardedPorts)\n\t\t\tresource.port = port\n\t\t}\n\t\tif !resource.started {\n\t\t\teventV2.TaskInProgress(constants.PortForward, \"port forward URLs\")\n\t\t\t// has not been started yet\n\t\t\tcctx, cancel := context.WithCancel(ctx)\n\t\t\toutput.Yellow.Fprintf(out, \"Forwarding service %s to local port %d\\n\", resource.name.String(), resource.port)\n\t\t\tcmd := exec.CommandContext(cctx, \"gcloud\", getGcloudProxyArgs(resource.name, resource.port)...)\n\t\t\tcmd.Stdout = out\n\t\t\tcmd.Stderr = out","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/cloudrun/accessor.go#L128-L164","documentation":"The Cloud Run port-forwarder (`runProxyForwarder.Start`) shells out to the `gcloud` CLI to create local proxy processes for Cloud Run services. Before starting any forward, it checks `gcloudInstalled()`; if the binary is not found on PATH it prints a message and returns this error with code PORT_FORWARD_RUN_GCLOUD_NOT_FOUND. No Cloud Run port-forwarding can be set up without gcloud.","triggerScenarios":"`Start` is called during `skaffold dev`/`run` port-forwarding setup while a Cloud Run deployer is active, and `exec.LookPath(\"gcloud\")` fails because the gcloud CLI is not installed or not on PATH for the process running skaffold.","commonSituations":"Fresh CI container or new machine without Google Cloud SDK; gcloud installed only for another user or in a venv not on PATH; running skaffold in a slim Docker build stage that lacks the SDK; PATH not sourced in the terminal/IDE launch environment.","solutions":["Install the Google Cloud SDK so `gcloud` is on PATH (https://cloud.google.com/sdk/docs/install)","Verify with `which gcloud` / `gcloud --version` in the same shell/environment where skaffold runs","If gcloud exists elsewhere, add its directory to PATH before launching skaffold (e.g. `export PATH=$PATH:/usr/local/google-cloud-sdk/bin`)","If you don't need Cloud Run port-forwarding, avoid the dev loop port-forward step for Cloud Run resources or use `skaffold run` instead of `skaffold dev`"],"exampleFix":"# before: skaffold dev fails with 'gcloud not found'\n# after:\nexport PATH=$PATH:$HOME/google-cloud-sdk/bin\nwhich gcloud && skaffold dev","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"gcloud\"); err != nil {\n\treturn fmt.Errorf(\"gcloud CLI is required for Cloud Run port-forwarding: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := forwarder.Start(ctx, out)\nif err != nil {\n\tvar sErr *sErrors.Error\n\tif errors.As(err, &sErr) && sErr.Status().ErrCode == proto.StatusCode_PORT_FORWARD_RUN_GCLOUD_NOT_FOUND {\n\t\tfmt.Fprintln(os.Stderr, \"Install the Google Cloud SDK: https://cloud.google.com/sdk/docs/install\")\n\t\tos.Exit(1)\n\t}\n\treturn err\n}","preventionTips":["Install the Google Cloud SDK as part of your dev-container/CI image definition","Add a preflight check (`command -v gcloud`) to your dev setup scripts","Export the SDK bin directory in shell profiles and CI PATH explicitly","Pin the gcloud version your team uses to avoid unrelated CLI drift"],"tags":["cloud-run","gcloud","port-forwarding","missing-binary"],"backgroundTag":"command-not-found-on-path","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}