swift-package-manager: [SR-8262] Swift Package Manager fails at checkout when dependent repository contains Git LFS objects

Previous ID SR-8262
Radar rdar://problem/42246102
Original Reporter yifei (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 2
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 2218c2c1d09b919e983b204e24d25058

Issue Description:

The error is in the format of: (XXXXX being the name of LFS-tracked file)

Error downloading object: XXXXX (hash): Smudge error: Error downloading XXXXX (hash): batch request: missing protocol: "/path/to/project/.build/repositories/dependency.git/info/lfs"

error: external filter 'git-lfs filter-process' failed
fatal: XXXXX: smudge filter lfs failed
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

This happens during the “cloneCheckout” phase i.e. invoking “git clone --shared”. If I disable the LFS filter by editing the global .gitconfig, the project builds fine.

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 14
  • Comments: 25 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Can we get an update on this please? It’s been open for 6 years but seems like a critical barrier preventing 100% adoption of Swift PM.

Is there any update to this?

The workaround from @briancordanyoung seem to work, but the Xcode path has changed

cd /Applications/Xcode.app/Contents/Developer/usr/bin
ln -s /opt/homebrew/bin/git-lfs git-lfs

One option for this I wrote up here (which only applies if the LFS files are something optional for your package, like test results): https://stackoverflow.com/questions/67457594/swift-package-manager-does-not-work-with-git-lfs/77336212#77336212

Not sure if it helps you, but I believe the .lfsconfig file has to be present on the repo’s default branch. When SPM clones the package it starts with the default branch and then checks out whichever branch/commit you requested.

This did ultimately end up working well enough for me, I was able to use xcodebuild in CI (but not the Xcode app): https://github.com/foxglove/MCAPSpotlightImporter/actions/runs/3380647041/jobs/5613664270

However, the .lfsconfig file is causing some other issues for developers working with the repo… 😓

Based on this thread and the forum discussion, I came to the same blocking errors.

Linking git-lfs did work in the sense that Xcode used it but reported a different error downloading various files that were checked in with lfs. The error included “Smudge error: Error downloading…”

> cd /Applications/Xcode-14.1.0.app/Contents/Developer
> ln -s /opt/homebrew/bin/git-lfs git-lfs

Adding a .lfsconfig (with an updated path for my repo) did not help with me when running swift build or an Xcode package resolution. I did have some GitHub authentication errors until I removed the commit that added the file.

The only work around I have is to manually clone the repo and include it as a local package—which of course negates all advantages of using a dependency manager. 😫

I did file FB11803523 for Xcode.

Thanks, this helps!