Can't checkout code


#1

I created an image to build my services in circleci, but I’m getting the following error:

Warning: Git is not installed in the image. Falling back to CircleCI’s native git client but this is still an experiment feature. We highly recommend using an image that has official Git installed.
Counting objects: 11379, done.
Compressing objects: 100% (8130/8130), done.
Total 11379 (delta 3840), reused 9479 (delta 2475)
worktree is not clean

I installed git in my image. With circleci/build-image:ubuntu-14.04-XL-922-9410082 git worked, but this image is so big :confused:


#2

Did you follow these instructions?

Be sure to include

    steps:
          # Ensure your image has git, otherwise the checkout step will fail
          - run: apt-get -qq update; apt-get -y install git

in your config.yml if your image doesn’t have git installed.

What image do you base your own image on?
You need to modify the above run command to use the package manager for your (Linux?) image.


#3

Just make sure you have git installed in your base image’s Dockerfile, something like:

RUN set -xe \
    && apt-get -y update \
    && apt-get install --no-install-recommends -y git

It should work. Also if you did this but still getting same error, it might be related to the fact that your image got cached, so instead of using :latest, bump image version and use a new one under your circle.yml.


#4

I’m using alpine. Here is my Dockerfile:

FROM ruby:2.4-alpine
RUN apk --update add git

I tagged my image and updated my .circleci/config.yml:

version: 2
jobs:
  build:
    docker:
      - image: fnix/build-image:0.1-alpine
    working_directory: /fnix
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Install dockerization tools
          command: |
            apk add docker py-pip
            pip install docker-compose
      - run:
          name: Build containers
          command: |
            docker build -t kdiogenes/fnix:web-alpine-$TAG .
            docker build -t kdiogenes/fnix:web-dev-alpine-$TAG -f Dockerfile.dev .
            if [[ $CIRCLE_BRANCH == 'master' ]]; then
              docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
              docker push kdiogenes/fnix:web-alpine
              docker push kdiogenes/fnix:web-dev-alpine
            fi

Same warning:

Warning: Git is not installed in the image. Falling back to CircleCI's native git client but this is still an experiment feature. We highly recommend using an image that has official Git installed.
Counting objects: 11401, done.
Compressing objects: 100% (8149/8149), done.
Total 11401 (delta 3852), reused 9479 (delta 2475)

At least the “worktree is not clean” has gone away.


#5

If you’re running into this error and you’re pretty certain git is installed, check your PATH in your UI environment variables. Some customers have something like PATH=/custom_path:$PATH in there, which interpolated correctly for 1.0.

On 2.0, variable expansion isn’t supported yet, so this clobbers your path and can cause this.


#6

I don’t deal with $PATH :confused:


#7

I have the same problem. I just created a very simple build image and added bash, git and java. When pulling the image locally and checking the packages are installed everything is working perfectly:

$ docker run -it reflectoring/build-image-java:latest /bin/sh
/ # git --version
git version 2.11.1
/ # bash --version
GNU bash, version 4.3.46(1)-release (x86_64-alpine-linux-musl)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
/ # java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (IcedTea 3.3.0) (Alpine 8.121.13-r0)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)
/ #

As soon as my PR build (org: reflectoring PR #208) picks up my image, I get an error

Warning: Git is not installed in the image. Falling back to CircleCI’s native git client but this is still an experiment feature. We highly recommend using an image that has official Git installed.
Counting objects: 3806, done.
Compressing objects: 100% (64/64), done.
Total 3806 (delta 12), reused 0 (delta 0), pack-reused 3728
reference not found

This is my Dockerfile and this my circle ci configuration.

This should serve well as a minimal example on how to reproduce the bug.


#9

I forwarded all that info onto our team. Thanks so much!


#10

@matthiasbalke @cerdiogenes

The reason why CircleCI thinks git is not installed is because the Docker image has git but not ssh which is needed by git because we checkout code with ssh protocol.

So, the error message “git is not installed in this image” is completely misleading. I’ll fix to something that makes more sense.

I’ll be investigating why our fallback git fails to clone but the easiest solution for now is adding “ssh” in your Dockerfile.


#11

Thanks that solved my problem. The error message is realy misleading. Thanks for pointing us into the right direction!


#12

Thanks @kimh!


#13

@kimh you should also update the docs. There are references to custom git like here:
https://circleci.com/docs/2.0/migrating-from-1-2/

Ensure your image has git, otherwise the checkout step will fail


#14

@matthiasbalke Thanks for pointing this out! Just submitted a PR


#15

I have a kinda similar problem, but I dont get any error it just says

====>> Spin up Environment
Build-agent version 0.0.5895-01cdb92 (2018-05-29T20:07:10+0000)
Starting container cypress/base:8
  using image cypress/base@sha256:740d461c0da849543a5b67611a426e8807263efe6cb0251e6e5feddc4288e3b0

Using build environment variables:
  BASH_ENV=/tmp/.bash_env-localbuild-1529056835
  CI=true
  CIRCLECI=true
  CIRCLE_BRANCH=cypress-query-params
  CIRCLE_BUILD_NUM=
  CIRCLE_JOB=cypress-tests
  CIRCLE_NODE_INDEX=0
  CIRCLE_NODE_TOTAL=1
  CIRCLE_REPOSITORY_URL=***
  CIRCLE_SHA1=f1b0540ea1b65ead39a44e777f852656d2ac2339
  CIRCLE_SHELL_ENV=/tmp/.bash_env-localbuild-1529056835
  CIRCLE_WORKING_DIRECTORY=~/project

====>> Checkout code
  #!/bin/sh
mkdir -p /root/project && cp -r /tmp/_circleci_local_build_repo/. /root/project

And it doesn’t move from this point.
Any sugesstions?


#16

Does the build step appear red or green? On the right hand side, does it display an exit code?


#17

Im trying to test it locally, it just spins forever no exit code or anything like that, could it be permissions?


#18

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.