CircleCI always fails to checkout code

At the checkout phase, CircleCI fails with following message:

fatal: destination path ‘.’ already exists and is not an empty directory.
Exited with code 128

It happens sometimes. A rerun of the job may fix it. But it’s just getting more and more annoying to manually restart the job each time.

Here attached the config.yml

# Scala CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/sample-config/ for more details
#
version: 2
jobs:
  build-test:
    docker:
      - image: ledgerhq/jdk8-scylla:1.0
    working_directory: ~/project
    environment:
      # Customize the SBT maximum heap limit
      SBT_OPTS: "-Xms128m -Xmx2g"
      TERM: dumb
    steps:
      - run:
          name: Clean workspace
          command: rm -rf ~/project
      - run:
          name: Start ScyllaDB
          command: /docker-entrypoint.py --listen-address localhost --memory 3G --smp 1 --overprovisioned 1
          background: true
      - checkout
      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "project/Dependencies.scala" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-
      - run: cat /dev/null | sbt test:compile test:test
      # save dependencies
      - save_cache:
          paths:
            - ~/.ivy2
            - ~/.sbt
          key: v1-dependencies--{{ checksum "project/Dependencies.scala" }}
  package:
    docker:
      - image: ledgerhq/jdk8-scylla:1.0
    working_directory: ~/project
    environment:
      # Customize the SBT maximum heap limit
      SBT_OPTS: "-Xmx1g"
      TERM: dumb
    steps:
      - run: rm -rf ~/project
      - checkout
      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "project/Dependencies.scala" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-
      # run tests!
      - run: cat /dev/null | sbt assembly
      - persist_to_workspace:
          root: ~/project
          paths:
            - assembly
            - dockerfiles
            - scripts
  tag_version-rolling:
    docker:
      - image: ledgerhq/jdk8-scylla:1.0
    working_directory: ~/project
    steps:
      - run: rm -rf ~/project
      - checkout
      - run: scripts/tag_version-rolling.sh
  docker:
    docker:
      - image: docker
    working_directory: ~/project
    environment:
    steps:
      - attach_workspace:
          at: ~/project
      - setup_remote_docker:
          docker_layer_caching: true
      - run:
          name: Docker build and push
          command: scripts/docker.sh
workflows:
  version: 2
  dev_pre-prod_prod:
    jobs:
      - build-test:
          filters:
            tags:
              only: /^v.*/
      - package:
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /^v.*/
          requires:
            - build-test
      - docker:
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /^v.*/
          requires:
            - package
      - tag_version-rolling:
          filters:
            branches:
              only:
                - master
            tags:
              ignore: /.*/
          requires:
            - build-test

You’re using checkout steps in downstream jobs. Use it in the job that runs first, and then use workspaces to persists any files that you need to downstream jobs.

Thanks for reply. Will this be the cause even the failure happened in the first job?

Maybe not. I tried running the Docker image locally and I can’t even get that to work though.