Skip to content
Latchkey

Cloud Functions "Build failed" on dependency install in CI

Cloud Functions builds your source with Cloud Build, which installs the dependencies in requirements.txt or package.json. If an install fails (bad pin, private package, no wheel), the build fails and the function is not deployed.

What this error means

gcloud functions deploy fails with "OperationError: code=3, message=Build failed" and a pip or npm install error in the embedded build log.

gcloud
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed:
`pip_download_wheels` returned code: 1
ERROR: Could not find a version that satisfies the requirement internal-utils==1.0.0
ERROR: No matching distribution found for internal-utils==1.0.0

Common causes

A pinned dependency cannot be resolved

A version that does not exist, or a private package the build cannot reach, makes the install step return non-zero and the build fail.

A native dependency has no compatible wheel

The function build environment cannot compile or find a wheel for a C-extension package, so the install aborts.

How to fix it

Pin to resolvable, published versions

  1. Read the embedded build log to find the package the install could not resolve.
  2. Correct the pin to a published version, or vendor a private package.
  3. Redeploy and confirm the build installs cleanly.
requirements.txt
# requirements.txt
flask==3.0.3
requests==2.32.3

Reproduce the build locally first

Install the same requirements in a clean environment to surface the failure before it reaches the deploy.

Terminal
python -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt

How to prevent it

  • Commit a tested, fully pinned requirements file.
  • Avoid private indexes the function build cannot authenticate to.
  • Prefer packages that publish wheels for the function runtime.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →