agents-cli icon indicating copy to clipboard operation
agents-cli copied to clipboard

FileNotFoundError on Windows due to missing .cmd extension in gcloud command

Open josendfa opened this issue 6 months ago • 8 comments

What happened?

When running agents-cli setup --workspace on Windows, the CLI crashes with a FileNotFoundError when attempting to check the Application Default Credentials (ADC).

This occurs because the script calls subprocess.run(["gcloud", ...]). On Windows, the Google Cloud CLI executable is named gcloud.cmd. Python's subprocess on Windows does not automatically resolve the .cmd extension without shell=True, causing it to fail to find the executable.

Steps to Reproduce

  1. Install agents-cli (v0.1.3) on a Windows 11 environment.
  2. Ensure the Google Cloud CLI (gcloud) is installed and authenticated.
  3. Run agents-cli setup --workspace
  4. See error.

What did you expect to happen?

The CLI should successfully detect the local gcloud installation, verify authentication, and continue the setup process.

Client information

Client Information

CLI version: 0.1.3 CLI install path: C:\Users\redacted\AppData\Roaming\uv\tools\google-agents-cli\Lib\site-packages\google\agents\cli OS info: Windows-11-10.0.26200-SP0 Installed skills: 7 (project)

  • google-agents-cli-adk-code
  • google-agents-cli-deploy
  • google-agents-cli-eval
  • google-agents-cli-observability
  • google-agents-cli-publish
  • google-agents-cli-scaffold
  • google-agents-cli-workflow

Project root: C:\Development\example-agent-1 Project name: example-agent-1 Deployment target: agent_runtime Agent directory: app Region: us-east1

Command Output / Logs

  1. Authentication ───────────────── agents-cli v0.1.3 Traceback (most recent call last): File "C:\Users\redacted\AppData\Roaming\uv\tools\google-agents-cli\Lib\site-packages\google\agents\cli\main.py", line 64, in invoke super().invoke(ctx)

File "C:\Users\redacted\AppData\Roaming\uv\tools\google-agents-cli\Lib\site-packages\click\core.py", line 1902, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "C:\Users\redacted\AppData\Roaming\uv\tools\google-agents-cli\Lib\site-packages\click\core.py", line 1298, in invoke return ctx.invoke(self.callback, **ctx.params) ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\redacted\AppData\Roaming\uv\tools\google-agents-cli\Lib\site-packages\click\core.py", line 853, in invoke return callback(*args, **kwargs) File "C:\Users\redacted\AppData\Roaming\uv\tools\google-agents-cli\Lib\site-packages\google\agents\cli\setup\cmd_setup.py", line 326, in cmd_setup authed, display = is_authenticated() ~~~~~~~~~~~~~~~~^^ File "C:\Users\redacted\AppData\Roaming\uv\tools\google-agents-cli\Lib\site-packages\google\agents\cli\auth.py", line 366, in is_authenticated if not _check_valid_adc(): ~~~~~~~~~~~~~~~~^^ File "C:\Users\redacted\AppData\Roaming\uv\tools\google-agents-cli\Lib\site-packages\google\agents\cli\auth.py", line 382, in _check_valid_adc subprocess.run( ~~~~~~~~~~~~~~^ ["gcloud", "auth", "application-default", "print-access-token", "--quiet"], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ check=True, ^^^^^^^^^^^ capture_output=True, ^^^^^^^^^^^^^^^^^^^^ ) ^ File "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.14-windows-x86_64-none\Lib\subprocess.py", line 555, in run with Popen(*popenargs, **kwargs) as process: ~~~~~^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.14-windows-x86_64-none\Lib\subprocess.py", line 1039, in init self._execute_child(args, executable, preexec_fn, close_fds, ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pass_fds, cwd, env, ^^^^^^^^^^^^^^^^^^^ ...<5 lines>... gid, gids, uid, umask, ^^^^^^^^^^^^^^^^^^^^^^ start_new_session, process_group) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.14-windows-x86_64-none\Lib\subprocess.py", line 1553, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ # no special security ^^^^^^^^^^^^^^^^^^^^^ ...<4 lines>... cwd, ^^^^ startupinfo) ^^^^^^^^^^^^ FileNotFoundError: [WinError 2] The system cannot find the file specified

Anything else we need to know?

Workaround:

As a local workaround, changing "gcloud" to "gcloud.cmd" on google/agents/cli/auth.py successfully resolves the issue.

A permanent, cross-platform fix in the codebase could involve using shutil.which("gcloud") to resolve the correct executable path dynamically, or explicitly appending .cmd if sys.platform == 'win32'.

josendfa avatar May 09 '26 19:05 josendfa

Analysis below was done by Claude (Anthropic, via Claude Code) while debugging this bug on my machine — sharing because it expands the scope of the issue. I'm not claiming credit for the investigation.

Reproduced on a separate Windows 11 / Python 3.14 / uvx install (different from the original uv tool install path), with the same root cause confirmed by an isolated repro:

>>> subprocess.run(['gcloud', '--version'])         # FileNotFoundError
>>> subprocess.run(['gcloud.cmd', '--version'])     # works
>>> shutil.which('gcloud')
'C:\...\google-cloud-sdk\bin\gcloud.CMD'

A few additions that may help whoever picks this up:

1. The bug class is broader than gcloud — it affects 5 external tools across 13+ call sites. The original report only covers _check_valid_adc. A grep across v0.1.3 site-packages turns up the same subprocess.run(['<tool>', ...]) pattern for gcloud, npx, npm, terraform, and gh:

Tool File Line Caller
gcloud auth.py 175 _get_gcloud_account
gcloud auth.py 383 _check_valid_adc (the one in the original report)
gcloud data/_helpers.py 28 project-id lookup
gcloud deploy/cmd_deploy.py 241 gcloud beta run deploy
gcloud deploy/cmd_deploy.py 354 gcloud services enable
gcloud deploy/cmd_deploy.py 434 project-id lookup
gcloud deploy/cmd_deploy.py 542 gcloud builds submit
gcloud infra/cmd_datastore.py 50 gcloud storage cp
gcloud scaffold/commands/create.py 936 project-id lookup
npx setup/cmd_setup.py 156 skills list during setup
npm scaffold/utils/language.py 101 npm install --package-lock-only
terraform deploy/cmd_deploy.py 507 terraform init
terraform infra/cmd_datastore.py 87 terraform -chdir=...
gh infra/_cicd_utils.py 494, 506 gh auth login --with-token

I hit the npx case during setup step 3 (Skills Installation):

> npx -y skills list --json
WARNING:root:Could not check for legacy skills: [WinError 2] El sistema no puede encontrar el archivo especificado

That one happens to be non-fatal because the surrounding code falls back to a hardcoded 'C:\Program Files\nodejs\npx.CMD' path on the next call. The terraform and gh cases will likely fail hard the same way gcloud does.

2. The codebase already has the correct helpers — they're just inconsistently applied. google/agents/cli/_tools.py defines require_tool() (uses shutil.which, with a Windows-specific fallback for gcloud) plus per-tool wrappers for every single one of the affected tools:

  • get_gcloud_path()
  • get_npx_path()
  • get_npm_path()
  • get_terraform_path()
  • get_gh_path()
  • get_git_path()

get_gcloud_path is already imported and used correctly in auth.py::_setup_google_cloud_adc (line 95) — it just wasn't applied to the other call sites. So the fix is one-line per site:

# before
subprocess.run(["gcloud", ...], ...)

# after
from google.agents.cli._tools import get_gcloud_path
subprocess.run([get_gcloud_path(), ...], ...)

Since the helpers already exist and already work on Windows, this isn't a new design decision — it's a consistency fix across ~13 call sites.

3. Confirmed local fix. Patching just the two auth.py sites (lines 175 and 383) to use get_gcloud_path() is enough to unblock agents-cli setup end-to-end on Windows, when ADC is already configured.

lenintorresact avatar May 10 '26 05:05 lenintorresact

Thank you for your feedback! We'll look into it right away.

Internal tracking: b/511715719

sushicw avatar May 11 '26 17:05 sushicw

If you are able, can you please clarify if this occurs only on 0.1.3, or on previous versions of agents-cli as well?

sushicw avatar May 11 '26 17:05 sushicw

Hello there.

This is the first version I tried to be honest, so I can not help you with that!

El lun, 11 may 2026 a las 12:40, Chris Wilson @.***>) escribió:

sushicw left a comment (google/agents-cli#14) https://github.com/google/agents-cli/issues/14#issuecomment-4423257186

If you are able, can you please clarify if this occurs only on 0.1.3, or on previous versions of agents-cli as well?

— Reply to this email directly, view it on GitHub https://github.com/google/agents-cli/issues/14#issuecomment-4423257186, or unsubscribe https://github.com/notifications/unsubscribe-auth/BJSM4SWVT4RAGKY6YJGEJOT42IGB3AVCNFSM6AAAAACYXNJIRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DIMRTGI2TOMJYGY . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

Lenin Torres Head of AI (+593-2) 392-3400

@.***

Av. Orellana E9-195 y Av. 6 de Diciembre, Edif. Alisal de Orellana, Of. 804. Quito - Ecuador

www.actuaria.com En Actuaria, actuamos por un mundo mejor con los ​objetivos de desarrollo sostenible. Términos y condiciones - Seguridad de la información

lenintorresact avatar May 11 '26 19:05 lenintorresact

I did some testing on my own and it looks like 0.1.1 works correctly, but as of 0.1.2 it breaks.

sushicw avatar May 11 '26 21:05 sushicw

We have some very relevant WIP work to better resolve command paths on Windows. We'll make sure it fixes this. It should land soon, stay tuned!

sushicw avatar May 11 '26 23:05 sushicw

Having the same issue from 0.1.2, was on 0.1.3, downgraded to 0.1.1, and works fine.

FotieMConstant avatar May 12 '26 10:05 FotieMConstant

This should be fixed in 0.2.0, just released.

sushicw avatar May 19 '26 01:05 sushicw