Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no .git folder #335

Open
medyagh opened this issue Aug 20, 2020 · 26 comments
Open

no .git folder #335

medyagh opened this issue Aug 20, 2020 · 26 comments

Comments

@medyagh
Copy link

medyagh commented Aug 20, 2020

minikube Make uses git log for getting the commit sha for minikube version,

git log doesn't work in checkouted source code

when I run git log --pretty=oneline
I get this error:

 Not a git repository (or any of the parent directories): .git
@Codelax
Copy link

Codelax commented Aug 27, 2020

If you are running on a self-hosted runner, is your CI checking out your project using git or github REST API ?

@RaiBnod
Copy link

RaiBnod commented Sep 9, 2020

I was using self-hosted runner. And it had no .git folder showed me logs as below:

Getting Git version info
  Working directory is '/root/actions-runner/_work/<project>/<project>'
  /usr/bin/git version
  git version 2.17.1
The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH
Downloading the archive
Writing archive to disk
Extracting the archive

This means, the repository got downloaded using the GitHub REST API, which meant to dowloaded differently.

So for debugging what's going around, I tried on the ubuntu-latest instead of self-hosted and it showed me log something like this:

Getting Git version info
  Working directory is '/home/runner/work/<project>/<project>'
  /usr/bin/git version
  git version 2.28.0
Initializing the repository
  /usr/bin/git init /home/runner/work/<project>/<project>
  Initialized empty Git repository in /home/runner/work/<project>/<project>/.git/
  /usr/bin/git remote add origin https://github.com/<org>/<project>
Disabling automatic garbage collection
  /usr/bin/git config --local gc.auto 0

After comparing those two logs: one is using Git version: 2.17.1, and another one is using Git version: 2.28.0.

Hence, after updating the Git version (>= 2.18) into latest one, the issue got resolved in my case.

@alexellis
Copy link

I'm using GitHub itself and not a self hosted runner but keep running into the same issue. We use the .git folder during our scripts.

@sohanyadav
Copy link

same issue :(

@yss14
Copy link

yss14 commented Nov 27, 2020

As @RaiBnod already mentioned, upgrading git did the trick for me, too (in my case 2.11.0 -> 2.21.0).

@HebaruSan
Copy link

HebaruSan commented Dec 10, 2020

Also seeing lack of .git folder, git reports git version 2.20.1 (believe we are in ubuntu-latest), are there any other known causes?

Why is this version-specific, hasn't git clone created a .git folder standardly for a very long time?

EDIT: Hmm, another version of git is active somehow somewhere? Thanks for the clues about what to investigate...

The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH

Is this referring to the copy of git installed inside of actions/checkout@v2? How can I upgrade that?

Tried apt-get install git as a step before checkout. Please kill me.

Package git is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'git' has no installation candidate

Is the root cause a TLS thing?

EDIT AGAIN: Apparently what I needed to do was delete this from the workflow file, because then it ... uses something newer? I have no idea:

       container:
           image: ubuntu:latest

I assume that's a restatement of what's already been said above. Included for anyone else who's as clueless as I am.

@pwoolvett
Copy link

Self hosted: upgrading git for debian-based distros:

sudo apt-get install -y software-properties-common \
    && sudo apt-get update \
    && sudo add-apt-repository -y ppa:git-core/ppa \
    && sudo apt-get update \
    && sudo apt-get install -y git

Either run it before the checkout action, or, if the runner is a docker container, add as a RUN command

@ktbarrett
Copy link

ktbarrett commented Feb 6, 2021

This was also an issue for me (due to use of setuptools_scm on a project I am running in a container) and it took me a good while to find this issue. I think this difference in behavior should be more prevalent in the README.

@lcooper-git
Copy link

I was using self-hosted runner. And it had no .git folder showed me logs as below:

Getting Git version info
  Working directory is '/root/actions-runner/_work/<project>/<project>'
  /usr/bin/git version
  git version 2.17.1
The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH
Downloading the archive
Writing archive to disk
Extracting the archive

This means, the repository got downloaded using the GitHub REST API, which meant to dowloaded differently.

So for debugging what's going around, I tried on the ubuntu-latest instead of self-hosted and it showed me log something like this:

Getting Git version info
  Working directory is '/home/runner/work/<project>/<project>'
  /usr/bin/git version
  git version 2.28.0
Initializing the repository
  /usr/bin/git init /home/runner/work/<project>/<project>
  Initialized empty Git repository in /home/runner/work/<project>/<project>/.git/
  /usr/bin/git remote add origin https://github.com/<org>/<project>
Disabling automatic garbage collection
  /usr/bin/git config --local gc.auto 0

After comparing those two logs: one is using Git version: 2.17.1, and another one is using Git version: 2.28.0.

Hence, after updating the Git version (>= 2.18) into latest one, the issue got resolved in my case.

Any ideas on getting the self-hosted up to a later version? I have the same issue but the older version of git is limiting other features we want. I need at least 2.18 or higher.

@FedericoCeratto
Copy link

2021-04-01: I still see the same problem when running on GitHub itself.

@amagana3
Copy link

amagana3 commented Apr 2, 2021

Self hosted: upgrading git for debian-based distros:

sudo apt-get install -y software-properties-common \
    && sudo apt-get update \
    && sudo add-apt-repository -y ppa:git-core/ppa \
    && sudo apt-get update \
    && sudo apt-get install -y git

Either run it before the checkout action, or, if the runner is a docker container, add as a RUN command

Even after running those ^ on a self-hosted docker image I still get the same errors. For some reason I only get a 2.7 version of GIT installed and nothing newer. Cannot seem to get past it.

@amagana3
Copy link

amagana3 commented Apr 2, 2021

UPDATE:

Got it working - rather than running git install on Dockerfile, just run it before the checkout phase like suggested above. Here's how mine looks:

steps:
      - name: Force Install GIT latest
        run: |
          apt-get install -y software-properties-common \
          && apt-get update \
          && add-apt-repository -y ppa:git-core/ppa \
          && apt-get update \
          && apt-get install -y git

      # Checkout the repository to the GitHub Actions runner
      - name: Checkout
        uses: actions/checkout@v2

Works on Ubuntu:18.04. Cheers 👍🏼

@FedericoCeratto
Copy link

I still see the failure when using git 2.20.1 Besides, updating is just a workaround: the bug should be fixed in order to support older git versions.

@ventz
Copy link

ventz commented Apr 27, 2021

@amagana3 The problem is you are modifying the "base os" of the runner with that.

Here is my solution to this bug, until it is fixed upstream -- "pipe" the action@v2 to run inside a docker context of ubuntu:20.04 and setup git (or use a container you have with git that will run checkout):

on:
  push:
    branches:
      - master
  pull_request:
jobs:
  some-job:
    name: some-job-name
    runs-on: ubuntu-latest
    container: ubuntu:20.04
    steps:
      - name: Obtain Latest Git ONLY within container for checkout
        run: |
          apt-get update
          apt-get install -y git

      - name: Checkout Repo Action
        uses: actions/checkout@v2

Key parts:

 runs-on: ubuntu-latest --> this is a self-hosted label. (in my case, Ubuntu 18.04)

vs

    container: ubuntu:20.04 --> this is the container used for the "actions/checkout@v2"

This is actually a pretty elegant solution to this problem imo.

@ventz
Copy link

ventz commented Apr 27, 2021

Here is a much smaller and quicker version via alpine:

on:
  push:
    branches:
      - master
  pull_request:
jobs:
  some-job:
    name: some-job-name
    runs-on: ubuntu-latest
    container: alpine:latest
    steps:
      - name: Obtain Latest Git ONLY within container for checkout
        run: apk add git --update-cache

      - name: Checkout Repo Action
        uses: actions/checkout@v2

Again, noting that alpine:latest is just used to run the actions/checkout@v2 and will provide the needed version of git.

@mrowles
Copy link

mrowles commented May 2, 2021

@ventz Thanks for this! However, using shell: bash fails when I add the container: alpine:latest line, I assume we now have to deal with this manually though.

Explicit error:

OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "bash": executable file not found in $PATH: unknown

@ventz
Copy link

ventz commented May 2, 2021

@mrowles Alpine doesn't have bash by default - it uses ash (the almquist shell)

If you need bash, you can just add it as a package to the pre-checkout line.
run: apk add git bash --update-cache

With that said, I suspect you may have something else going on within your action config, because in this case the 'container: alpine:latest' is only used for the checkout action, and the "run" before it is to populate the alpine container. (ex: if we were using another image that had git, or for example ubuntu -- we would not need that step). So, I am assuming you are adding additional steps which are not wrapping other actions, and thus not executed with the container? (ex: directly with the run command?).

@mrowles
Copy link

mrowles commented May 2, 2021

@ventz Got it! So I'll need to install bash, aws etc. if I was to use anything not provided. No dramas, thanks for the help!

For future people, my main problem is not so much the .git folder missing, but actually the .yarn folder, so I'm seeing if updating git fixes this also.

@ventz
Copy link

ventz commented May 9, 2021

@mrowles Yes. My suggestion is to keep it all wrapped into nice clean containers that you own, and then just call them either directly, or with custom actions. It makes the actions yaml config very clean, fast, and efficient. (Especially if you are not installing things you won't need at each run. Again, the git example above is not this on purpose to demonstrate use case)

@spnda
Copy link

spnda commented Jun 4, 2021

I would like to add my personal findings. Adding the following to the GH Actions workflow file, actions/checkout@v2 will not create the .git folder, or atleast all other actions I use complain about the current directory not being a git repository. And the OpenJDK should not be interfering with any git operations or actions.

    container:
      image: openjdk:16-jdk

Simply removing the snippet, the workflow works fine again. I have run a simple test workflow just earlier and I've noticed that with the OpenJDK image, git does not seem to exist on PATH, and actions/checkout@v2 therefore does not git clone and instead uses the GitHub REST API to download the repository. You can also see how the working directory is somewhere completely different in the two runs. See https://github.com/spnda/ghactionstest/actions/runs/907433837.

So this seems to rather be an issue with actions or docker not setting up the environment properly and not with this action, no?

k-okada added a commit to k-okada/opencv_apps that referenced this issue May 23, 2022
k-okada added a commit to k-okada/opencv_apps that referenced this issue May 23, 2022
k-okada added a commit to k-okada/opencv_apps that referenced this issue May 23, 2022
k-okada added a commit to k-okada/opencv_apps that referenced this issue May 23, 2022
k-okada added a commit to k-okada/opencv_apps that referenced this issue May 23, 2022
k-okada added a commit to k-okada/opencv_apps that referenced this issue May 23, 2022
k-okada added a commit to k-okada/opencv_apps that referenced this issue May 23, 2022
k-okada added a commit to k-okada/opencv_apps that referenced this issue May 23, 2022
k-okada added a commit to k-okada/opencv_apps that referenced this issue May 23, 2022
k-okada added a commit to k-okada/opencv_apps that referenced this issue May 24, 2022
k-okada added a commit to k-okada/opencv_apps that referenced this issue May 24, 2022
k-okada added a commit to k-okada/opencv_apps that referenced this issue May 24, 2022
marshall7m added a commit to marshall7m/pytest-terra-fixt that referenced this issue May 25, 2022
@acottre
Copy link

acottre commented May 10, 2023

This causes an issue here: actions/runner#763

JustSamuel added a commit to GEWIS/sudosos-POS that referenced this issue Jun 16, 2023
CodeNamedRobin pushed a commit to GEWIS/sudosos-POS that referenced this issue Jun 16, 2023
* - Implements a build hash string shown on the login page
- Also fixes the borrel mode logout bug whoeps
- Implemented AB testing

* Implements AB testing in the workflows

* Woops

* Potential fix to get the .git dir

* Fix was at the devvm

* actions/checkout#335

* Maybe upgrade git works.

* This works.

* This works.
JustSamuel added a commit to GEWIS/sudosos-POS that referenced this issue Jun 16, 2023
JustSamuel added a commit to GEWIS/sudosos-POS that referenced this issue Jun 28, 2023
* Production A/B Testing (#17)

* - Implements a build hash string shown on the login page
- Also fixes the borrel mode logout bug whoeps
- Implemented AB testing

* Implements AB testing in the workflows

* Woops

* Potential fix to get the .git dir

* Fix was at the devvm

* actions/checkout#335

* Maybe upgrade git works.

* This works.

* This works.

* Update docker.yml

* Update docker.yml

* Banner Fix (#18)

* Banner timeout works now finally.

* Update common.scss

* Update Home.vue
@gskema
Copy link

gskema commented Apr 4, 2024

For those looking to solve this issue this worked for me:
#701 (comment)
There is also fetch-tags: true option for actions/checkout but that didn't seem to work
#579

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests