pub
pub copied to clipboard
Support git-lfs files in the lib directory
Problem
The caching that pub does for git refs breaks git-lfs files that are in the lib directory. (https://git-lfs.github.com/ for reference) I have a file in the lib directory that is in LFS in repo A. Repo B has a pubspec dependency on repo A as a git ref.
running pub get
causes pub to bare clone the repo into .pub-cache/git/cache/REPO
and then clones from that filesystem location into .pub-cache/git/name-HASH
The 2nd clone can't pull down the file from the LFS server since that repo is now a filesystem based clone and does not know where to find the LFS server.
Solution
Instead of cloning from .pub-cache/git/cache as a filesystem, you could copy the bare repo directory to .pub-cache/git/REPO-hash/.git and modify the config file to set bare = false
and then checkout the working directory. This would preserve the actual origin so the LFS file can be found.
I invite comments on this approach or suggestions for alternatives but I'd like to see LFS files work in lib directories in some manner.
Can you go into more detail about what exactly is going wrong? Why doesn't the clone preserve the LFS target URL?
I would like to solve this, but I don't think manually copy-pasting the repo is the right way to do so. git
is very good at reusing resources when cloning locally, and I don't want to ditch that functionality everywhere to support a small fraction of the use-cases.
This issue is still happening, and just popped up for me while I tried to add this component https://github.com/jadennn/flutter_ijk to a flutter project.
@robrbecker Did you find a workaround for this issue (besides creating intermediate repositories)?
@ened Nope. I just avoided the problem by not using git-lfs.
Is it still not fixed?
I am trying to use git lfs in my flutter project and getting the error as follow:
1m 38s
Run flutter build apk
💪 Building with sound null safety 💪
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
/home/runner/work/REPO/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.
/home/runner/work/REPO/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
/home/runner/work/REPO/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.
----Same for rest of the images.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 35s
Running Gradle task 'assembleRelease'... 96.6s
Gradle task assembleRelease failed with exit code 1
Error: Process completed with exit code 1.
I confirmed the types of PNG files using https://stackoverflow.com/a/27670182/5163725.
Not sure what the issue is, any help will be appreciated thanks.
I have same issue. I add my LFS repo to dependency_overrides and pub get fails with "smudge error", can't download LFS files. I found that (with --verbose), pub get clones the repository twice:
git clone --mirror repo.git .pub-cache/git/cache/repo
and later
git clone.pub-cache/git/cache/repo .pub-cache/git/repo
Because mirroring does not download LFS files, the second clone will fail. The only solution is call git lfs fetch --all
after mirroring, --bare
not working neither.
I made a PR for this https://github.com/dart-lang/pub/pull/3289
I made some investigations:
It is only happen if
Disable LFS makes error go away, but it's only means LFS files not downloads. Compile will fail.git-lfs
installed and enabled on computer. If you disable with git lfs uninstall
(do not run in a LFS repository, or use --skip-repo
to leave current LFS repo untouched), the error will go away. Git downloads objects as LFS only if git-lfs
installed. For compatibility reasons I think.
Are there by any chance any further updates on this? Or is disabling LFS on the original plugin repository still the only "solution" for now?
I have same issue. Any updates?
https://github.com/dart-lang/pub/pull/2782