Cross-posting from GitHub as suggested by the triage bot: SwifterPM restore fails on git hosts that reject shallow fetches (buf.build): no full-fetch fallback · Issue #12647 · tuist/tuist · GitHub
Summary
tuist install fails to restore Swift packages hosted on git servers that reject shallow fetches — in our case the generated SDKs on buf.build (https://buf.build/gen/swift/git/``...).
SwifterPM’s source restore (ensureSource in swifterpm/Sources/swifterpm/Restore.swift) has exactly two strategies:
downloadSourceArchive— only implemented for GitHub/GitLab, so it throws for any other host;shallowFetchCheckout—git fetch --depth=1 origin <revision>, with no fallback.
buf.build’s git server does not support shallow clients (uploadpack.allowShallow off), so step 2 fails with fatal: Server does not support shallow clients and the whole install fails. A plain (non-shallow) git fetch origin <revision> of the same pin succeeds against the same server.
Expected: the restore falls back to a non-shallow fetch (like SwiftPM does) when the server rejects --depth, instead of failing the install.
Reproduction (no auth needed, the package is public)
Standalone:
mkdir repro && cd repro && git init .
git remote add origin https://buf.build/gen/swift/git/1.24.2-20241219201140-e93e34f48be0.1/googleapis_googleapis_grpc_swift.git
# what SwifterPM runs — fails:
git fetch --depth=1 origin 13244576b21a339b077ed7ef1e029710bcf2ae24
# fatal: Server does not support shallow clients
# same fetch without --depth — succeeds:
git fetch origin 13244576b21a339b077ed7ef1e029710bcf2ae24
Through Tuist: add the package to Tuist/Package.swift of any generated project and run tuist install with a cold source cache:
.package(url: "https://buf.build/gen/swift/git/1.24.2-20241219201140-e93e34f48be0.1/googleapis_googleapis_grpc_swift.git", exact: "1.24.2-20241219201140-e93e34f48be0.1")
Resolution itself succeeds (SwiftPM handles it) — only the SwifterPM restore step fails. A warm source cache masks the bug, which is why it surfaced for us only after a version bump left the cache cold for these pins.
Error log
✖ Error
failed to restore googleapis_googleapis_grpc_swift from https://buf.build/gen/swift/git/1.24.2-20241219201140-e93e34f48be0.1/googleapis_googleapis_grpc_swift.git at 13244576b21a339b077ed7ef1e029710bcf2ae24: could not fetch any candidate location ...:
- ...: fatal: Server does not support shallow clients
fatal: the remote end hung up unexpectedly
Proposed fix
Catch the --depth=1 failure inside shallowFetchCheckout and retry with a plain git fetch origin <revision> before propagating the error.
Workaround: TUIST_USE_SWIFTERPM=0 works fine.
Environment: Tuist 4.205.0, Xcode 26.6, macOS 26.6.2