uv: uv doesn't correctly checkout Git dependencies with Git LFS assets
I’m working on a project that depends on a private Git repository where some of the project’s assets are stored in Git LFS (in this case Pytorch models).
My project uses Rye as its package manager. When configured to use Pip, everything works as expected. When configured to use uv, the LFS objects aren’t checked out correctly.
I assume a blocker for uv supporting LFS is the fact that the git2 crate also doesn’t support LFS (rust-lang/git2-rs#956) and there’s no indication support will be added in the future.
Platform: Ubuntu 22.04 uv version: 0.1.39
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 18
- Comments: 16 (5 by maintainers)
Another workaround option if you need LFS for other repos and don’t want to manually set environment variables:
Create a new file
~/.gitconfig-nolfs.inc:Create or modify
~/.gitconfig:This updates your Git config to skip LFS just for uv dependencies.
Adding another workaround here. Running
git lfs install --force --skip-smudgebefore installing the dependency from your private repo did solve it for us. I was able to install withuv addafter that.Same issue here. Makes uv unfortunately unusable for us since we have lfs in a private github repo.
Still running into this issue using uv 0.3.0.
uvfails due togit lfsfailing due to “smudge errors”.Sample command:
pipworks fine, so my current workaround is:Cloning the repo locally and then installing from a local path works fine too.
I’ve investigated this a bit more and I think I now understand the actual source of the error.
When getting a Git revision
uvwill first fetch the rev to a local repo, then do a local clone to a new directory, then do a hard reset of the cloned repo to the specific revision. The last step is what’s triggering the LFS error. When the files are being checked out, the LFS smudge filter will try to resolve LFS pointers to actual files, but fails because LFS doesn’t know the URL of the upstream remote.I think it’s possible to fix this by just adding a step where after the initial fetch but before the local clone
uvwould try to rungit lfs fetch <remote> <rev>. This resolves the smudge error because it ensures all of the LFS pointers are present in the Git database when the hard reset happens.The biggest issue I see with that approach is that since LFS has to check every file in a revision when fetching, it’s possible that for large repositories the overhead could become non-trivial.
On the other hand since the command would only run if the user has Git LFS installed, it would really only affect the specific subset of users who:
No clue how, but setting the environment variable
GIT_LFS_SKIP_SMUDGE=1does have the desired effect.This old comment suggests that certain local checkouts might trigger these problems https://github.com/git-lfs/git-lfs/issues/2518#issuecomment-863218693. Not sure whether that is the case here though.
Sure.
The workaround above works, though it might not actually get the lfs-file I checked in (I didn’t check). Packages that use LFS likely need their LFS files 😉
@thesofakillers you’ll need to open a new issue with a clear reproduction
I seem to be still getting this issue. Running on mac M3. i’ve udpated
uvwithuv self updateandgitandgit-lfswithbrew update && brew upgrade git git-lfsEDIT: as requested, i’ve opened a new issue #12938
Just for reference, I tried setting the respective settings @vfilter suggested in https://github.com/astral-sh/uv/issues/3312#issuecomment-2323443935 as environment variables
which is also picked up by git
However when running
uv sync --upgrade-package <my-package-in-git>I still get the smudge filter error.@zanieb could it be that uv does not pass on the environment variables to the underlying git process? (Setting them via the config file works).
We actually stopped using the git2 crate so we may be able to support this easier now? cc @ibraheemdev