# SwifterPM restore fails on git hosts that reject shallow fetches (buf.build) — no full-fetch fallback

**URL:** https://community.tuist.dev/t/swifterpm-restore-fails-on-git-hosts-that-reject-shallow-fetches-buf-build-no-full-fetch-fallback/1016
**Category:** Troubleshooting & how to
**Created:** [October 12, 2026, 5:52am UTC](https://community.tuist.dev/t/swifterpm-restore-fails-on-git-hosts-that-reject-shallow-fetches-buf-build-no-full-fetch-fallback/1016 "2026-10-12T05:52:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kvyatkovskys](https://community.tuist.dev/user_avatar/community.tuist.dev/kvyatkovskys/32/964_2.png) [@kvyatkovskys](https://community.tuist.dev/u/kvyatkovskys)
#### Post date: [October 12, 2026, 5:52am UTC](https://community.tuist.dev/t/swifterpm-restore-fails-on-git-hosts-that-reject-shallow-fetches-buf-build-no-full-fetch-fallback/1016/1 "2026-10-12T05:52:14Z")

</div>

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](https://github.com/tuist/tuist/issues/12647)

## 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:

1. `downloadSourceArchive` — only implemented for GitHub/GitLab, so it throws for any other host;
2. `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:

```auto
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:

```auto
.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

```auto
✖ 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
