Skip to content
Latchkey

Azure Pipelines "You have an existing checkout in the current directory"

A checkout step found the working directory already populated from a previous checkout in the same job. Either you have multiple checkout steps into the same path, or a self-hosted agent kept a stale workspace.

What this error means

A checkout step fails with You have an existing checkout in the current job directory, telling you to clean or use a distinct path. It commonly appears on self-hosted agents that reuse the workspace, or when checking out multiple repos.

Azure DevOps
##[error]You have an existing checkout in the current job directory.
Please clean the current job's working directory or specify a different
path for the checkout.

Common causes

Multiple repos checked out to the same path

Checking out more than one repository without giving each a distinct path collides in the default sources directory.

Stale workspace on a self-hosted agent

Self-hosted agents reuse the working directory between runs. A leftover checkout from a prior job conflicts with the new one unless the workspace is cleaned.

How to fix it

Give each checkout a distinct path

When checking out multiple repos, set path per checkout so they don’t collide.

azure-pipelines.yml
steps:
  - checkout: self
    path: s/app
  - checkout: git://OtherProject/tools
    path: s/tools

Clean the workspace on self-hosted agents

Enable workspace cleaning so each run starts fresh.

azure-pipelines.yml
jobs:
  - job: build
    workspace:
      clean: all      # outputs | resources | all
    steps:
      - checkout: self

How to prevent it

  • Set workspace: { clean: all } on jobs running on reused self-hosted agents.
  • Assign a unique path to each repo when using multiple checkouts.
  • Avoid duplicate checkout steps targeting the same directory.

Frequently asked questions

What causes ""existing checkout in the directory""?
Checking out more than one repository without giving each a distinct path collides in the default sources directory.
How do I fix "existing checkout in the directory"?
When checking out multiple repos, set path per checkout so they don’t collide.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card