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 continueCommon 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 gitEnsure git is on PATH
- Confirm the binary exists with
which git. - Add its directory to PATH for the step if it is installed but not found.
- 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 --versionin an early CI step. - Keep tool prerequisites (git, curl) in your base image.
Related guides
SwiftPM "Couldn't get the list of tags" in CIFix SwiftPM "error: Couldn't get the list of tags" in CI - SwiftPM could not read the dependency's tags, usua…
SwiftPM "failed to clone ... authentication failed" for a private package in CIFix SwiftPM "error: failed to clone ... authentication failed" in CI - a private SPM dependency needs an SSH…
SwiftPM "dependency 'X' could not be resolved" in CIFix SwiftPM "error: 'X' dependency ... could not be resolved" in CI - SwiftPM could not satisfy a requirement…