5

How to install git-lfs on an Amazon EC2 (Amazon Linux 2) instance?

Based on https://github.com/git-lfs/git-lfs/blob/main/INSTALLING.md did I tried:

sudo yum install git -y;
cd /home/ec2-user;
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash
   -> which tells me afterwards: 
   The repository is setup! You can now install packages.
sudo yum install git-lfs
   -> gives me: 
   Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
   No package git-lfs available.
   Error: Nothing to do

Future commands (not possible yet duo git: 'lfs' is not a git command. See 'git --help'. after git lfs install) would than be based on https://git-lfs.github.com/

git lfs install
...
git clone https://yourrepo.git;

Amazon Linux 2 AMI (HVM) - Kernel 5.10, SSD Volume Type / Arm

MJey
  • 345
  • 3
  • 16
  • 1
    did you try running `yum update/upgrade` before? I don't have an EC2 instance to test, but I used the amazonlinux docker image and I was able to install following your instructions. – Juan Fontes Mar 12 '22 at 09:59
  • @JuanFontes Thank you for the hint, unfortunately do I still get "No package git-lfs available." on the EC2 instance itself. :/ – MJey Mar 13 '22 at 15:01

3 Answers3

13

With Amazon Linux 2, you can use the Extras Library to install application and software updates on your instances. These software updates are known as topics.

Below are the steps:

  1. Connect to your EC2 Linux instance using SSH.

  2. Use the which command to confirm that the amazon-linux-extras package is installed:

    $ which amazon-linux-extras

    /usr/bin/amazon-linux-extras

If the amazon-linux-extras package isn't installed, you can use yum to install it:

$ sudo yum install -y amazon-linux-extras

To list the available topics, you can use the following command:

$ amazon-linux-extras list
  1. git-lfs usually comes as part of the epel-release, so you need to first to install epel release for Amazon Linux:
    $ sudo amazon-linux-extras install epel -y 

For the Amazon Linux AMI, access to the Extra Packages for Enterprise Linux (EPEL) repository is configured, but it is not enabled by default.

    $ sudo yum-config-manager --enable epel
  1. Now you can install git-lfs or whatever else you like from epel-release:
    $ sudo yum install git-lfs
Arpit Jain
  • 1,599
  • 9
  • 23
  • If you get `/var/lang/bin/python: No module named amazon_linux_extras`, you may need to force amazon-linux-extras to use Python 2 if Python 3 is installed: `PYTHON=python2 amazon-linux-extras install epel -y` [source](https://stackoverflow.com/a/69614110). – Gabriel Devillers Jun 02 '22 at 12:49
  • If you get `/bin/sh: yum-config-manager: command not found` you may need to install `yum-utils` first: `yum install -y yum-utils` – Gabriel Devillers Jun 02 '22 at 12:51
4

As described on packagecloud[1], you need to run:

curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash

to install the dependencies and the repos. Alternatively you can take the script from [1] directly. You can then simply install with yum:

sudo yum install git-lfs

[1] https://packagecloud.io/github/git-lfs/install#bash-rpm

Thomas Jungblut
  • 20,854
  • 6
  • 68
  • 91
  • Thank you @Thomas for your response. Did you tested it on an AWS EC2? Your code lines are the exact same lines I mentioned in the problem description. And still don't work for me yet. :/ – MJey Mar 13 '22 at 14:57
  • @MJey yep tested and worked. Maybe include your error message in your question? – Thomas Jungblut Mar 13 '22 at 15:22
0

You need to directly install the ARM64 git-lfs binaries:

wget https://github.com/git-lfs/git-lfs/releases/download/v3.1.2/git-lfs-linux-arm64-v3.1.2.tar.gz

sudo yum install git -y

tar -xvf git-lfs-linux-arm64-v3.1.2.tar.gz

sudo ./install.sh

git lfs install

Now, enjoy your GIT-LFS on ARM64.