actions / checkout

Action for checking out a repo
https://github.com/features/actions
MIT License
5.94k stars 1.76k forks source link

git-lfs cannot be found in a self-hosted runner #1401

Open fengwang opened 1 year ago

fengwang commented 1 year ago

Steps to reproduce

  1. Install actions-runner-linux-x64-2.299.2 in Archlinux/Ubuntu1804, setup token and service
  2. Create an action script in folder .github/workflows including
name: CI

on:
  push:
    branches: [ "main", "workflow" ]
  pull_request:
    branches: [ "main", "workflow" ]

jobs:

  build:
    runs-on: self-hosted

    steps:
      - name: cleanup
        run: |
          echo Will clean from here.
          echo $PATH
          whoami
          echo Clean is skipped.
          which git
          uname -a
          which apt
          echo $PATH

      - uses: actions/checkout@v3
        with:
          lfs: true
          submodules: 'recursive'
          token: ${{ secrets.ACCESS_TOKEN }}

        env:
          GIT_CURL_VERBOSE: '1'
          GIT_TRACE: '1'

I encountered build error with message

[build](https://github.xxxxxxxx.com/xxxxxx/XXXXXXXXXX/actions/runs/396556/jobs/633216#step:3:23)
Unable to locate executable file: git-lfs. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.

The cleanup step produces information like this:

Run echo Will clean from here.
Will clean from here.
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
azureuser
Clean is skipped.
/usr/bin/git
Linux AIC-GithubActionsRunner 5.[1](https://github.xxx.com/xxxxxx/XXXXXXXX/actions/runs/396556/jobs/633216#step:2:1)5.0-1033-azure #40~20.04.1-Ubuntu SMP Tue Jan 24 [16](https://github.xxxxxxxx.com/xxxxxx/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/actions/runs/396556/jobs/633216#step:2:17):06:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
/usr/bin/apt
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

The checkout step produces error information

Run actions/checkout@v3
Syncing repository: XXXXXXXX/xxxxxxxx
Getting Git version info
  Working directory is '/home/azureuser/actions-runner/_work/XXXXXXXX/XXXXXXXX'
  /usr/bin/git version
  [20](https://github.xxxxxxxxxx.com/xxxxxx/XXXXXXXX/actions/runs/396556/jobs/633216#step:3:21):09:09.676113 git.c:439               trace: built-in: git version
  git version 2.25.1
  Error: Unable to locate executable file: git-lfs. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.

Note:

  1. XXXXXXX and xxxxxx are sensitive information get masked
  2. git-lfs is already installed and configured in the host system (ArchLinux/Ubuntu 1804)
jbelien commented 6 months ago

Same issue here (also on a self-hosted runner)! image

jbelien commented 4 months ago

To avoid this issue, here is the step I've added before the actions/checkout:

- name: Initialize LFS
  run: |
    curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
    sudo apt-get install git-lfs
jpr5 commented 1 month ago

To avoid this issue, here is the step I've added before the actions/checkout:

- name: Initialize LFS
  run: |
    curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
    sudo apt-get install git-lfs

How does that even work? The self-runner I'm using on Linux doesn't have sudo installed. And it appears stuff doesn't run as root so you can't call apt-get directly. How'd that work for you @jbelien ?