Skip to content
Latchkey

SwiftPM "could not find 'git'" fatalError in CI

SwiftPM shells out to git to clone and resolve dependencies. If no git binary is on PATH, resolution cannot start and SwiftPM reports it could not find git.

What this error means

swift package resolve or swift build fails early complaining it could not find git, typically on a slim container image without git installed.

swift
error: could not find 'git' in the PATH or the toolchain; install git to continue

Common causes

A minimal image without git

A slim Swift container omits git to stay small, so SwiftPM has no binary to clone dependencies with.

git present but not on the step PATH

git is installed elsewhere but not on the PATH the SwiftPM step sees.

How to fix it

Install git on the runner

Add git before the resolve step so SwiftPM can clone dependencies.

Terminal
# Debian/Ubuntu based Swift image
apt-get update && apt-get install -y git

Ensure git is on PATH

  1. Confirm the binary exists with which git.
  2. Add its directory to PATH for the step if it is installed but not found.
  3. Re-run resolution.
Terminal
which git || echo "git missing"

How to prevent it

  • Use a Swift image that already bundles git, or install it in image setup.
  • Verify git --version in an early CI step.
  • Keep tool prerequisites (git, curl) in your base image.

Related guides

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