CircleCI-Public / CircleCI-Public/gcp-cli-orb

`gcp-cli/setup` fails when pre-installed SDK version falls behind `latest` in environments without `sudo`

Open
#98 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
10
Forks
34
PR merge metrics
No merged PRs in 30d

Description

When using `gcp-cli/setup` without a pinned version (defaulting to `latest`), the orb scrapes the release notes and determines the latest version is 560.0.0. However, the execution environment already has 559.0.0 installed. Because the versions differ, the orb enters the `uninstall()` path, which requires `sudo` — and fails if `sudo` is not available in the container.

This affects the `gcp-cli/google` executor (where the baked-in SDK version lags behind the latest release).

I believe #80 addressed a related issue in v3.3.1, but this scenario still occurs when Google publishes a new SDK version before the executor image is updated.

**Steps to reproduce:**

1. Use `gcp-cli/setup` with default version (`latest`)
2. Run in an environment where gcloud is pre-installed at a version behind latest (e.g., 559.0.0 when 560.0.0 is the latest release)
3. The container does not have `sudo` installed

**Error output:**

```
/bin/bash: line 141: python: command not found
Detected platform: linux ()
The version installed (559.0.0) differs from the version requested (560.0.0).
Uninstalling v559.0.0...
sudo is required to uninstall the Google Cloud SDK.
Please install it and try again.
Failed to uninstall the current version.

Exited with code exit status 1
```

**Desired behavior:**

The orb should handle the case where a slightly older version is already installed without requiring `sudo` to uninstall. Possible approaches:

- Install the new version to a user-writable directory alongside the existing one, rather than requiring an uninstall
- Fall back gracefully if `sudo` is unavailable (e.g., warn and continue with the installed version)
- Don't attempt to upgrade when the installed version is close to latest

**Secondary issue:**

The script also references `python` (not `python3`) on this line:

```bash
printf "Detected platform: %s (%s)\n" "${platform}" "$(python --version)"
```

Many modern images only have `python3` available, causing a `command not found` error. This doesn't block execution but is noisy.

**Workaround:**

Pin the version parameter to match the pre-installed SDK version:

```yaml
- gcp-cli/setup:
version: 559.0.0
```

**Environment:**

- Orb version: `circleci/gcp-cli@3.3.0`
- Executors: `gcp-cli/google`
- Date: March 2026

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the gcp-cli/setup script's version detection, uninstall path, and platform message that calls python. Reproduce with an older pre-installed SDK and no sudo, then verify that setup handles the version mismatch without requiring sudo and uses an available Python command without noisy errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
google-cloud, shell
Domain
cli, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.