Builds fail after new commit to git-lfs

Hi,

I’ve switched my git repository (bitbucket) to use LFS for storing images. I’m not using Netlify large media. I’m noticing that whenever I add a new image to my repository, builds fail until I go into the netlify dashboard and trigger ‘Clear cache and deploy site’.

7:25:09 AM: Error checking out branch: Downloading static/uploads/2019/06/ONLIC.jpg (49 KB)
Error downloading object: static/uploads/2019/06/ONLIC.jpg (736daa2): Smudge error: Error downloading static/uploads/2019/06/ONLIC.jpg (736daa2d5e115ed1380da8f0828d38da06abbf27157fda54589b35468baea943): batch request: missing protocol: ""

Errors logged to /opt/build/repo/.git/lfs/logs/20190609T212509.938580537.log
Use `git lfs logs last` to view the log.
error: external filter 'git-lfs filter-process' failed
fatal: static/uploads/2019/06/ONLIC.jpg: smudge filter lfs failed
7:25:09 AM: Failing build: Failed to prepare repo
7:25:10 AM: failed during stage 'preparing repo': exit status 128
7:25:10 AM: Finished processing build request in 20.622859125s
7:25:10 AM: Shutting down logging, 0 messages pending

Once I do this, the (hugo) site builds straight away, and continues to rebuild when I make regular commits of markdown files.

Is there anything I can do to ensure the deploys don’t fail?

1 Like

If cloning a repository using LFS, we recommend using an environment variable GIT_LFS_ENABLED in our documentation here. Quoting:

  • If you set a GIT_LFS_ENABLED variable, we’ll use git lfs clone to check out your repository — otherwise we just use git clone .

You can add the environment variable by going to Site Name > Settings > Build & deploy > Environment. Or by replacing <your-subdomain-here> with your Netlify subdomain in the URL below:

https://app.netlify.com/sites/<your-subdomain-here>/settings/deploys#environment

It is interesting that it appears to be attempting an LFS clone without this environment variable being used. I still suspect this missing variable may be the root cause.

Would you be willing to please test this?

​Please let us know if there are any questions and/or if this doesn’t resolve the issue.

1 Like

Thanks Luke. I’ve put the variable in my netlify.toml file, and will check it with the next site update.

1 Like

Ok, so I’ve committed a new image to Git (LFS) and it’s failed:

This is the log from Netlify

10:50:20 AM: Preparing Git Reference refs/heads/master
10:50:22 AM: Error checking out branch: Downloading static/uploads/2019/07/TWH4.jpg (48 KB)
Error downloading object: static/uploads/2019/07/TWH4.jpg (26c5492): Smudge error: Error downloading static/uploads/2019/07/TWH4.jpg (26c54920485c7aa233af523cb19d5ba40436cc2a6030efefcb5f573135ce327d): batch request: missing protocol: ""

Errors logged to /opt/build/repo/.git/lfs/logs/20190701T005022.311748072.log
Use `git lfs logs last` to view the log.
error: external filter 'git-lfs filter-process' failed
fatal: static/uploads/2019/07/TWH4.jpg: smudge filter lfs failed

The first few lines of my netlify.toml says

[build]
publish = "public"
command = "hugo --minify"

[context.production.environment]
HUGO_VERSION = "0.55.6"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"
GIT_LFS_ENABLED = "true"

Have I made a mistake in my configuration, or is there something else I need to do? Thanks.

I encountered the same “smudge filter lfs failed” error when I added LFS images to my Bitbucket git repository. Setting GIT_LFS_ENABLED to true fixed the problem for me.

However I didn’t set it in netlify.toml, I set it on the Netlify website at Settings > Build & deploy > Environment > Environment variables. I suspect setting it in netlify.toml couldn’t work because wouldn’t that file only be read after the image has been checked out of git without LFS enabled?

1 Like

Thanks @gtch. Now you mention it, all the documentation I read mentioned setting GIT_LFS_ENABLED true in the netlify control panel rather than in netlify.toml. I couldn’t understand why that was the case, but your post makes perfect sense! Thanks.

1 Like

And for later searchers…this announcement/FAQ thread is a good place to go for problems with environment variables.

Great catch, and exactly correct, @gtch!