LFS files aren't downloaded during build

Hi

Site: roobottom.com
Build output:

2:31:33 PM: Build ready to start
2:31:36 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
2:31:36 PM: build-image tag: v3.4.1
2:31:36 PM: buildbot version: fcbc7a79f7372e5995cf02954ef19fc48d20c871
2:31:36 PM: Building without cache
2:31:36 PM: Starting to prepare the repo for build
2:31:36 PM: Git LFS enabled
2:31:36 PM: Configured environment variable GIT_LFS_ENABLED=true conflicts with Netlify Large Media.
2:31:36 PM: If you are moving from another LFS service, make sure to migrate all LFS files to Netlify, then remove GIT_LFS_ENABLED variable from your Netlify Build & deploy settings.
2:31:36 PM: Failing build: Failed to prepare repo
2:31:36 PM: Failed during stage 'preparing repo': Conflict LFS setup
2:31:37 PM: Finished processing build request in 221.625954ms

I have recently moved my image files in github to github’s git-lfs provider. I wish these to be downloaded and processed by my build script.

I think I need to disable netlify large media.

Can someone help or advise please?

Hi @roobottom!

Images stored in Git-LFS are not accessible during the build process.
You can follow the instructions to uninstall git lfs Here

1 Like

OK, thanks.

Are you saying that I can’t store LFS file in github then have them downloaded during my build process? I.e., I can’t use Githib’s LFS and have the files available on my website?

Thanks,

Nope :slight_smile:

He’s saying that during build the files aren’t there.
At serve time, we do send them to the browser :wink:

1 Like

Thanks for the replies. I appreciate your time in helping me understand this.

I’m still a bit lost - as isn’t cloning from github part of the build process? My build resizes all my images, so if they’re not available at build they won’t be resized (new files created) and won’t be available to the browser.

Cheers,

Netlify’s build process is not requesting the assets stored in Git-lfs.
3 reasons to consider to keep images in LFS:

  1. Netlify can automatically resize your images using request Params and will be cached automatically. (You can find more information in Netlify Docs)
  2. You have tons of images( or other media assets) the build process itself slows down not just during build but also with actually getting these assets delivered to the build process.
  3. Saving space in your git repo.

Reasons to consider removing Images from git-lfs:

  1. if you have your custom image manipulation process, which you want to control or want more freedom With images
  2. Want to generate .webp files or other exotic formats
  3. You have a few images which won’t Grow by lot in the future

Between these choices there are other images providers you can consider like Cloudinary.

If have more questions, please ask them, we will be more then happy to help!

Hi, @roobottom, I also want to chime in here to make some finer points clear:

  • Large Media is Netlify’s Git LFS service.
  • If you use Git LFS, you are not required to use Large Media. (You can use the Git LFS provided by the repo host: meaning Bitbucket, GitLab, GitHub.)
  • The raw images are available during site build with other Git LFS services but not with Large Media.
  • Image resizing works at browse time (post build) with Large Media but not with other Git LFS services.

Using the Git host’s Git LFS service or the Netlify’s Git LFS service (Large Media) is either/or. You can use one or the other, but not both. Switching back and forth between them can be done (but isn’t “simple” so changing often would require a fair amount of work).

If you use Large Media (Netlify’s Git LFS service), it enables image resizing after deploy when the image is requested (at browse time).

If you other Git LFS services you can image resize during the site build but not after (unless you “build & deploy” again to resize again).

To summarize, you can do build time image transformations with Git LFS stored files provided those files are using the Git host Git LFS service.

If that is your goal (using Git LFS and doing build time image processing), please let us know. The next steps will be to uninstall the Large Media add-on from the site and then using the environment variables for Git LFS to ensure our build system does download the actual file (instead of the Git LFS text pointer). That is done with the environment variable of GIT_LFS_ENABLED=true.

Again, please let us know if you want to uninstall Large Media based on the information above. This is a manual process our support team can complete. If we should uninstall Large Media, please read the Large Media uninstall guide first and let us know when you are ready to proceed.

3 Likes

Thanks, @luke - this makes things clear.

I’ll reply on the other post in #admin

1 Like

Hi, @luke. Is it possible to also cache the files pulled from Git LFS? Otherwise, each build just consumes a lot of bandwidth.

Hi, @hoangbn. This should already be the default behavior. Our build system does cache the repo between builds so the git pull should only need to download new or changed files.

If you are not seeing this happen, please let us know and our support team will take a look to find out why it isn’t working as expected.

1 Like

I wonder why it was working fine with images stored on GitLab LFS (we do build time image compression) but totally fails with video files

Interesting, so apparently Netlify downloads images from external LFS regardless of env variables set. But, for bigger files it needs both GIT_LFS_ENABLED=TRUE and GIT_LFS_FETCH_INCLUDE=* to be set.
Is it that unusual for users to store media files in LFS though?

No, it’s normal. I’m not sure why adding environment variables makes this abnormal. Git LFS might include a lot of files that your site might not need. We’d rather not spend time downloading all that and using your LFS bandwidth.