git-lfs icon indicating copy to clipboard operation
git-lfs copied to clipboard

Unable to install to Amazon Linux 2

Open ayeganyan-atl opened this issue 11 months ago • 4 comments

Hello,

Is there anything broken in the repository? I am following the guide to install the git lfs into my Amazon Linux 2 image/Ec2 machine, however I am getting this:

$ curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash
# ....
$ sudo yum install git-lfs
Failed to set locale, defaulting to C
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main                                                                                                                          | 2.1 kB  00:00:00
amzn-updates                                                                                                                       | 3.7 kB  00:00:00
github_git-lfs/x86_64/signature                                                                                                    |  819 B  00:00:00
github_git-lfs/x86_64/signature                                                                                                    |  951 B  00:00:00 !!!
github_git-lfs-source/signature                                                                                                    |  819 B  00:00:00
github_git-lfs-source/signature                                                                                                    |  951 B  00:00:00 !!!
No package git-lfs available.
Error: Nothing to do

ayeganyan-atl avatar Mar 11 '25 20:03 ayeganyan-atl

Hey, I'm sorry you're having trouble.

I'm not familiar with Amazon Linux 2 specifically, but examining Packagecloud's script, it looks like they may map all Amazon Linux versions to RHEL 6, while some online sources suggest Amazon Linux 2 was derived from RHEL 7.

    else
      aws=`grep -q Amazon /etc/issue`
      if [ "$?" = "0" ]; then
        dist='6'
        os='aws'
      else
        unknown_os
      fi
    fi

The answers to this Stack Overflow question, which is similar yours, don't mention the RHEL version differences, but do offer some other solutions to the problem, so you could try those.

Meanwhile, the answers to this question about another package hosted on Packagecloud do describe the RHEL version detection issue, and this post on another site offers a different solution, which I'll quote here and adapt for Git LFS, in case it's helpful. Note, though, that I have not tested this myself.

$ curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh?os=el&dist=7 | sudo bash
$ sudo yum install git-lfs

Let us know if you find something that works!

chrisd8088 avatar Mar 12 '25 16:03 chrisd8088

@chrisd8088 @ayeganyan-atl

Hi there,

It seems that the issue you're facing with installing Git LFS on Amazon Linux 2 is due to the Packagecloud installation script mapping Amazon Linux to an older RHEL 6 version, while Amazon Linux 2 is actually derived from RHEL 7. This mismatch can prevent the git-lfs package from being found.

To resolve this, you can try the following:

  1. Run this command to fetch the repository script that’s correctly mapped to RHEL 7-based systems:

    curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh?os=el&dist=7 | sudo bash
    
  2. Then, install Git LFS with:

    sudo yum install git-lfs
    

Alternatively, if that doesn’t work, I suggest checking out this GitHub repository for a tailored setup that should work with Amazon Linux 2: Strong-Foundation git-lfs-setup

This repo has been designed for easier installation on Amazon Linux 2 and could provide better support for both users.

Let me know how it goes or if you need any further assistance!

Best, Strong Foundation

Strong-Foundation avatar Mar 16 '25 23:03 Strong-Foundation

This script includes the following:

1* Proper detection of the current distribution and version.

2* Addition of the Git LFS repository to the system.

3* Handling the installation of Git LFS with error checks.

4* Enabling Git LFS after installation. Make sure you run this script with root privileges to install the necessary packages and repositories. Save the script to a file, for example, install-git-lfs.sh, and run it with sudo bash install-git-lfs.sh.


#!/bin/bash

Exit immediately if a command exits with a non-zero status

set -e

Define a function to install Git LFS on RPM-based distributions

install_git_lfs_rpm() {

Detect the current distribution

if [ -f /etc/os-release ]; then . /etc/os-release CURRENT_DISTRO=$ID CURRENT_DISTRO_MAJOR_VERSION=${VERSION_ID%%.*} else echo "Unsupported distribution or missing /etc/os-release" exit 1 fi

Set the Git LFS GPG Key URL

GIT_LFS_GPG_KEY="https://packagecloud.io/github/git-lfs/gpgkey"

Update the package lists and install required packages

yum check-update || true yum install -y git pygpgme yum-utils

Import the GPG key for the GitHub Git LFS repository

rpm --import ${GIT_LFS_GPG_KEY}

Add the GIT LFS repository to the system

cat <<EOF >/etc/yum.repos.d/github_git-lfs.repo [github_git-lfs] name=github_git-lfs baseurl=https://packagecloud.io/github/git-lfs/${CURRENT_DISTRO}/${CURRENT_DISTRO_MAJOR_VERSION}/$basearch repo_gpgcheck=1 gpgcheck=0 enabled=1 gpgkey=${GIT_LFS_GPG_KEY} sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300

[github_git-lfs-source] name=github_git-lfs-source baseurl=https://packagecloud.io/github/git-lfs/${CURRENT_DISTRO}/${CURRENT_DISTRO_MAJOR_VERSION}/SRPMS repo_gpgcheck=1 gpgcheck=0 enabled=1 gpgkey=${GIT_LFS_GPG_KEY} sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 EOF

Update the package lists to include the Git LFS repository

yum check-update || true

Install Git LFS using yum

if yum install -y git-lfs; then echo "Git LFS installed successfully." else echo "Failed to install Git LFS. No package available." exit 1 fi

Enable Git LFS

git lfs install }

Call the install_git_lfs_rpm function to install Git LFS on RPM-based distributions

install_git_lfs_rpm

Creatur3245 avatar Apr 01 '25 13:04 Creatur3245

Hey @Creatur3245,

I saw that you're working with Git LFS, and I wanted to share a script I put together that makes the setup process much easier:

🔗 GitHub Repo – Git LFS Setup

It should help streamline everything, and if you run into any issues, feel free to reach out—I’m happy to support you!

Let me know how it works for you. 🚀

Best, Strong Foundation

Strong-Foundation avatar Apr 01 '25 22:04 Strong-Foundation